Skip to content

Commit 83492e4

Browse files
committed
Update to React v18 and change root render
Update packages
1 parent 8ae788a commit 83492e4

5 files changed

Lines changed: 3875 additions & 3984 deletions

File tree

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
yarn type-check && yarn test && yarn lint-staged

package.json

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-dark-mode-toggle-2",
3-
"version": "2.0.3",
3+
"version": "3.0.0",
44
"description": "An updated, cute dark mode toggle button for React.",
55
"module": "dist/index.es.js",
66
"types": "dist/index.d.ts",
@@ -38,7 +38,8 @@
3838
"storybook": "start-storybook -p 6006",
3939
"build-storybook": "build-storybook",
4040
"build": "yarn type-check && vite build",
41-
"prepublishOnly": "yarn build"
41+
"prepublishOnly": "yarn build",
42+
"prepare": "husky install"
4243
},
4344
"repository": "",
4445
"author": "Todd Elvers <todd.elvers+github@gmail.com>",
@@ -48,40 +49,40 @@
4849
"lottie-web": "5.7.14"
4950
},
5051
"devDependencies": {
51-
"@babel/core": "^7.15.8",
52-
"@emotion/css": "^11.5.0",
53-
"@rollup/plugin-typescript": "^8.3.0",
54-
"@storybook/addon-actions": "^6.3.12",
55-
"@storybook/addon-essentials": "^6.3.12",
56-
"@storybook/addon-links": "^6.3.12",
57-
"@storybook/react": "^6.3.12",
58-
"@types/jest": "^27.0.2",
59-
"@types/react": "^16.14.11 || ^17.0.0",
60-
"@types/react-dom": "^16.9.14 || ^17.0.0",
61-
"@vitejs/plugin-react-refresh": "^1.3.1",
62-
"babel-loader": "^8.2.3",
63-
"husky": "^4.3.8",
64-
"jest": "^27.3.1",
65-
"lint-staged": "^11.2.5",
66-
"lottie-web": "^5.7.14",
67-
"prettier": "^2.4.1",
68-
"react": "^16.14.0 || ^17.0.0",
69-
"react-dom": "^16.14.0 || ^17.0.0",
52+
"@babel/core": "^7.18.6",
53+
"@emotion/css": "^11.9.0",
54+
"@rollup/plugin-typescript": "^8.3.3",
55+
"@storybook/addon-actions": "^6.5.9",
56+
"@storybook/addon-essentials": "^6.5.9",
57+
"@storybook/addon-links": "^6.5.9",
58+
"@storybook/react": "^6.5.9",
59+
"@types/jest": "^28.1.5",
60+
"@types/react": "^18.0.0",
61+
"@types/react-dom": "^18.0.0",
62+
"@vitejs/plugin-react": "^2.0.0",
63+
"babel-loader": "^8.2.5",
64+
"husky": "^8.0.0",
65+
"jest": "^28.1.3",
66+
"lint-staged": "^13.0.3",
67+
"lottie-web": "^5.9.6",
68+
"prettier": "^2.7.1",
69+
"react": "^18.0.0",
70+
"react-dom": "^18.0.0",
7071
"rimraf": "^3.0.2",
71-
"rollup": "^2.58.3",
72-
"rollup-plugin-typescript2": "^0.30.0",
73-
"ts-jest": "^27.0.7",
74-
"ts-loader": "^9.2.6",
75-
"ts-node": "^10.4.0",
76-
"typescript": "^4.4.4",
77-
"vite": "^2.6.13"
72+
"rollup": "^2.76.0",
73+
"rollup-plugin-typescript2": "^0.32.1",
74+
"ts-jest": "^28.0.5",
75+
"ts-loader": "^9.3.1",
76+
"ts-node": "^10.9.1",
77+
"typescript": "^4.7.4",
78+
"vite": "^3.0.0"
7879
},
7980
"peerDependencies": {
80-
"react": "^16.14.0 || ^17.0.0",
81-
"react-dom": "^16.14.0 || ^17.0.0"
81+
"react": "^18.0.0",
82+
"react-dom": "^18.0.0"
8283
},
8384
"dependencies": {
84-
"react-lottie-player": "^1.4.1"
85+
"react-lottie-player": "^1.4.3"
8586
},
8687
"husky": {
8788
"hooks": {

src/main.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as React from "react";
2-
import * as ReactDOM from "react-dom";
1+
import React from "react";
2+
import { createRoot } from "react-dom/client";
33
import { DarkModeToggle } from "./index";
44

55
const ControlledDarkModeToggle = () => {
@@ -24,9 +24,10 @@ const ControlledDarkModeToggle = () => {
2424
);
2525
};
2626

27-
ReactDOM.render(
27+
const container = document.getElementById("root");
28+
const root = createRoot(container!);
29+
root.render(
2830
<React.StrictMode>
2931
<ControlledDarkModeToggle />
30-
</React.StrictMode>,
31-
document.getElementById("root")
32+
</React.StrictMode>
3233
);

vite.config.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { defineConfig } from "vite";
2-
import reactRefresh from "@vitejs/plugin-react-refresh";
1+
import { defineConfig } from 'vite';
2+
import reactRefresh from '@vitejs/plugin-react';
33
// import typescript from "rollup-plugin-typescript2";
4-
import typescript from "@rollup/plugin-typescript";
4+
import typescript from '@rollup/plugin-typescript';
55

66
// https://vitejs.dev/config/
77
export default defineConfig({
@@ -10,27 +10,27 @@ export default defineConfig({
1010
build: {
1111
// Instruct Vite to bundle this project as a library
1212
lib: {
13-
entry: "src/index.tsx",
14-
name: "animated-dark-mode-toggle",
15-
formats: ["cjs", "es"],
13+
entry: 'src/index.tsx',
14+
name: 'animated-dark-mode-toggle',
15+
formats: ['cjs', 'es'],
1616
fileName: (format) => `index.${format}.js`,
1717
},
1818

1919
rollupOptions: {
2020
// Don't bundle react or react-dom
21-
external: ["react", "react-dom"],
21+
external: ['react', 'react-dom'],
2222

2323
output: {
2424
globals: {
2525
// Globally define React for UMD builds
26-
react: "React",
26+
react: 'React',
2727
},
2828
},
2929

3030
plugins: [
3131
typescript({
3232
// Ensure declaration files are outputted to our dist directory
33-
tsconfig: "./tsconfig.lib.json",
33+
tsconfig: './tsconfig.lib.json',
3434
}),
3535
],
3636
},

0 commit comments

Comments
 (0)