Skip to content

Commit

Permalink
chore: upgrade core-js to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
brickspert committed Nov 10, 2021
1 parent ec49be2 commit a68592d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"loose": true,
"modules": false,
"targets": "> 0.25%, not dead",
"useBuiltIns": "usage"
"useBuiltIns": "usage",
"corejs": 3
}
],
"@babel/react"
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
],
"dependencies": {
"@ahooksjs/use-request": "^3.0.0-alpha.0",
"core-js": "^2.6.12",
"core-js": "^3.19.1",
"dayjs": "^1.9.1",
"intersection-observer": "^0.7.0",
"js-cookie": "^2.2.1",
Expand Down
14 changes: 0 additions & 14 deletions packages/hooks/src/utils/depsAreSame.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
import type { DependencyList } from 'react';

if (!Object.is) {
Object.is = function (x, y) {
// SameValue algorithm
if (x === y) {
// Steps 1-5, 7-10
// Steps 6.b-6.e: +0 != -0
return x !== 0 || 1 / x === 1 / y;
} else {
// Step 6.a: NaN == NaN
return x !== x && y !== y;
}
};
}

export default function depsAreSame(oldDeps: DependencyList, deps: DependencyList): boolean {
if (oldDeps === deps) return true;
for (let i = 0; i < oldDeps.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion packages/use-url-state/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"dependencies": {
"ahooks": "^3.0.0-alpha.2",
"core-js": "^2.6.12",
"core-js": "^3.19.1",
"query-string": "^6.9.0"
}
}
30 changes: 30 additions & 0 deletions umd.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Hello World</title>
<script src="https://unpkg.com/react@17/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>

<!-- Don't use this in production: -->
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
</head>
<body>
<div id="root"></div>
<script src="./packages/hooks/dist/ahooks.js"></script>

<script type="text/babel">
const { useToggle } = window.ahooks;
const Demo = () => {
const [show, { toggle }] = useToggle(false);
return (
<div>
<button onClick={toggle}>Toggle</button>
{show && <div>Hello World</div>}
</div>
);
};
ReactDOM.render(<Demo />, document.getElementById('root'));
</script>
</body>
</html>

0 comments on commit a68592d

Please sign in to comment.