Skip to content

Commit a3b94d0

Browse files
fix: πŸ› React 18 strict mode double animation (#94) (#95)
* fix: πŸ› React 18 strict mode double animation * chore: πŸ€– changeset Co-authored-by: SamuelOsborne <[email protected]>
1 parent 232e143 commit a3b94d0

15 files changed

+9146
-134
lines changed

β€Ž.changeset/red-clouds-help.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@lottiefiles/react-lottie-player': patch
3+
---
4+
5+
fix double animation with react 18 strict mode

β€Žbabel.config.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
const { CODE_COVERAGE } = process.env;
21
const plugins = [];
3-
if (CODE_COVERAGE === 'true') plugins.push('istanbul');
2+
if (process.env.NODE_ENV === 'test') plugins.push('istanbul');
43

54
module.exports = function(api) {
65
api.cache(true);
+14-36
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,16 @@
1-
const path = require('path');
2-
3-
/* Allows importing code from other packages in a monorepo. Explanation:
4-
When you use lerna / yarn workspaces to import a package, you create a symlink in node_modules to
5-
that package's location. By default Webpack resolves those symlinks to the package's actual path,
6-
which makes some create-react-app plugins and compilers fail (in prod builds) because you're only
7-
allowed to import things from ./src or from node_modules
8-
*/
9-
const disableSymlinkResolution = {
10-
plugin: {
11-
overrideWebpackConfig: ({ webpackConfig }) => {
12-
webpackConfig.resolve.symlinks = false;
13-
return webpackConfig;
14-
},
15-
},
16-
};
17-
18-
const webpackSingleModulesResolution = {
19-
configure: {
20-
resolve: {
21-
symlinks: false,
22-
modules: [
23-
path.resolve('../../dist/lottie-react.js'),
24-
],
25-
},
26-
},
27-
};
28-
29-
const eslintOff = {
30-
enable: false
31-
}
32-
1+
const path = require('path')
2+
const CracoAlias = require("craco-alias");
333

344
module.exports = {
35-
plugins: [disableSymlinkResolution],
36-
webpack: webpackSingleModulesResolution,
37-
eslint: eslintOff
38-
};
5+
plugins: [
6+
{
7+
plugin: CracoAlias,
8+
options: {
9+
unsafeAllowModulesOutsideOfSrc : true,
10+
aliases: {
11+
'@lottiefiles/react-lottie-player': path.resolve('../../dist/lottie-react.esm.js'),
12+
}
13+
}
14+
}
15+
]
16+
};

β€Žcypress/react-testing-pages/package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
"@testing-library/jest-dom": "^5.16.2",
88
"@testing-library/react": "^12.1.3",
99
"@testing-library/user-event": "^13.5.0",
10-
"react": "^17.0.2",
11-
"react-dom": "^17.0.2",
10+
"react": "^18.1.0",
11+
"react-dom": "^18.1.0",
1212
"react-router": "^6.2.2",
1313
"react-router-dom": "^6.2.2",
14-
"react-scripts": "5.0.0",
14+
"react-scripts": "5.0.1",
1515
"web-vitals": "^2.1.4"
1616
},
1717
"scripts": {
@@ -37,5 +37,8 @@
3737
"last 1 firefox version",
3838
"last 1 safari version"
3939
]
40+
},
41+
"devDependencies": {
42+
"craco-alias": "^3.0.1"
4043
}
4144
}

0 commit comments

Comments
Β (0)