Skip to content

Commit

Permalink
[chore] Upgrade to react 18 (keplergl#2323)
Browse files Browse the repository at this point in the history
  • Loading branch information
igorDykhta authored Sep 24, 2023
1 parent 52c69c5 commit a0e5db7
Show file tree
Hide file tree
Showing 82 changed files with 1,322 additions and 319 deletions.
6 changes: 4 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"jestPuppeteer": true
},
"parser": "@typescript-eslint/parser",
"plugins": ["babel", "prettier", "react", "@typescript-eslint"],
"plugins": ["babel", "prettier", "react", "@typescript-eslint", "enzyme-deprecation"],
"rules": {
"valid-jsdoc": 0,
"no-var": 0,
Expand All @@ -43,7 +43,9 @@
"no-undef": 0,
"camelcase": 0,
"consistent-return": 0,
"comma-dangle": 1
"comma-dangle": 1,
"enzyme-deprecation/no-shallow": 2,
"enzyme-deprecation/no-mount": 2
},
"overrides": [
{
Expand Down
6 changes: 3 additions & 3 deletions bindings/kepler.gl-jupyter/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@
"kepler.gl": "^2.5.5",
"node-polyfill-webpack-plugin": "^1.1.2",
"querystring": "0.2.1",
"react": "^17.0.2",
"react": "^18.2.0",
"react-copy-to-clipboard": "^5.0.2",
"react-dom": "^17.0.2",
"react-dom": "^18.2.0",
"react-helmet": "^5.2.0",
"react-intl": "^3.12.0",
"react-intl": "^6.3.0",
"react-redux": "^7.1.3",
"redux": "^3.7.2",
"redux-actions": "^2.2.1",
Expand Down
32 changes: 22 additions & 10 deletions contributing/DEVELOPERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ export MapboxAccessToken=<insert_your_token>
yarn start
```

An demo app will be served at

```text
http://localhost:8080/
```
An demo app will be served at `http://localhost:8080/`

This is the demo app we hosted on [http://kepler.gl/#/demo][demo-app]. By default, it serves non-minified source code inside the src directory.

Expand Down Expand Up @@ -112,7 +108,7 @@ yarn test-headless
1. add `.only` to errored tests to only run 1 test at a time
```js
test.only('MapContainerFactory', t => {
// tests
// tests
}
```
Expand All @@ -131,6 +127,22 @@ To generate a coverage report
yarn cover
```
## Test React components
Enzyme is no longer supported therefore we are now transitioning to [testing library](https://testing-library.com/).
We have introduced an eslint rule to deprecate the usage of enzyme so if you attempt to create new tests using enzyme
it will throw an error when running lint.
In order to create new tests cases please take advantage of [Testing Library](https://testing-library.com/).
All necessary dependencies are already installed, you can start testing your React components by following this
[doc](https://testing-library.com/docs/react-testing-library/intro);
### Migrating enzyme to React testing library
If you are interested in migrating enzyme tests to RTL (react testing library) feel free to check
the [official migration guidelines](https://testing-library.com/docs/react-testing-library/migrate-from-enzyme/)
## Coding Rules
To ensure consistency throughout the source code, keep these rules in mind as you are working:
Expand Down Expand Up @@ -276,7 +288,7 @@ Netlify is connected to the following github triggers:
A new production version of kepler.gl website is automatically created and deployed every time a PR is merged onto master.
In order to support testing environment, Netlify is setup to generate build every time a PR is created or updated.
By generating builds for new and updated PRs we support CI/CD so developers can test their own build in a production like environment
By generating builds for new and updated PRs we support CI/CD so developers can test their own build in a production like environment
### Publish kepler.gl package to NPM
Expand Down Expand Up @@ -314,16 +326,16 @@ The documentation layout is defined by __SUMMARY.md__ file where the table of co
* [ENTRY_LABEL](FILE_PATH)
e.g.
* [Welcome](README.md)
```
```
The above file is used by Gitbook to generate the doc navigation visible on the left-hand side of Kepler.gl doc website.
The above file is used by Gitbook to generate the doc navigation visible on the left-hand side of Kepler.gl doc website.
Gitbook also has the ability to show description for each folder/section of the documentation by creating an entry in __SUMMARY.md__
and create a new __README.md__ file within said folder. The README.md file is a Gitbook convention that treats README files as if they were the main entry file for each folder.
The following is an example of doc section in SUMMARY.md file:
```markdown
* [User guides](docs/user-guides/README.md)
```
```
### Update Documentation
The integration with Gitbook allows to update the documentation in two different ways:
Expand Down
1 change: 1 addition & 0 deletions examples/custom-map-style/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</style>
</head>
<body>
<div id="root" />
<script src='bundle.js'></script>
</body>
</html>
6 changes: 3 additions & 3 deletions examples/custom-map-style/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"global": "^4.3.0",
"@kepler.gl/components": "^3.0.0-alpha.0",
"@kepler.gl/reducers": "^3.0.0-alpha.0",
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-palm": "^3.3.6",
"react-redux": "^7.1.3",
"react-virtualized": "^9.21.0",
Expand All @@ -28,4 +28,4 @@
"webpack-dev-server": "^3.1.14",
"webpack-hot-middleware": "^2.24.3"
}
}
}
6 changes: 4 additions & 2 deletions examples/custom-map-style/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
// THE SOFTWARE.

import React from 'react';
import ReactDOM from 'react-dom/client';
import document from 'global/document';
import {Provider} from 'react-redux';
import {render} from 'react-dom';
import store from './store';
import App from './app';

Expand All @@ -31,4 +31,6 @@ const Root = () => (
</Provider>
);

render(<Root />, document.body.appendChild(document.createElement('div')));
const root = ReactDOM.createRoot(document.getElementById('root'));

root.render(<Root />);
1 change: 1 addition & 0 deletions examples/custom-reducer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</style>
</head>
<body>
<div id="root" />
<script src='bundle.js'></script>
</body>
</html>
4 changes: 2 additions & 2 deletions examples/custom-reducer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"@kepler.gl/actions": "^3.0.0-alpha.0",
"@kepler.gl/components": "^3.0.0-alpha.0",
"@kepler.gl/reducers": "^3.0.0-alpha.0",
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-palm": "^3.3.6",
"react-redux": "^7.1.3",
"react-virtualized": "^9.21.0",
Expand Down
6 changes: 4 additions & 2 deletions examples/custom-reducer/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
// THE SOFTWARE.

import React from 'react';
import ReactDOM from 'react-dom/client';
import document from 'global/document';
import {Provider} from 'react-redux';
import {render} from 'react-dom';
import store from './store';
import App from './app';

Expand All @@ -31,4 +31,6 @@ const Root = () => (
</Provider>
);

render(<Root />, document.body.appendChild(document.createElement('div')));
const root = ReactDOM.createRoot(document.getElementById('root'));

root.render(<Root />);
1 change: 1 addition & 0 deletions examples/custom-theme/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</style>
</head>
<body>
<div id="root" />
<script src="/bundle.js"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions examples/custom-theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"global": "^4.3.0",
"@kepler.gl/components": "^3.0.0-alpha.0",
"@kepler.gl/reducers": "^3.0.0-alpha.0",
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-palm": "^3.3.6",
"react-redux": "^7.1.3",
"react-virtualized": "^9.21.0",
Expand Down
8 changes: 5 additions & 3 deletions examples/custom-theme/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@
// THE SOFTWARE.

import React from 'react';
import ReactDOM from 'react-dom/client';
import document from 'global/document';
import {render} from 'react-dom';
import {Provider} from 'react-redux';
import App from './app';
import store from './store';
import App from './app';

const Root = () => (
<Provider store={store}>
<App />
</Provider>
);

render(<Root />, document.body.appendChild(document.createElement('div')));
const root = ReactDOM.createRoot(document.getElementById('root'));

root.render(<Root />);
1 change: 1 addition & 0 deletions examples/demo-app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</style>
</head>
<body>
<div id="root" />
<script src="/bundle.js"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions examples/demo-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"@kepler.gl/styles": "^3.0.0-alpha.0",
"lodash.debounce": "^4.0.8",
"lodash.get": "^4.4.2",
"react": "^16.8.4",
"react": "^18.2.0",
"react-copy-to-clipboard": "^5.0.1",
"react-dom": "^16.8.4",
"react-dom": "^18.2.0",
"react-markdown": "^4.2.2",
"react-palm": "^3.3.6",
"react-redux": "^7.1.3",
Expand Down
2 changes: 1 addition & 1 deletion examples/demo-app/src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export function loadSample(options, pushRoute = true) {
return (dispatch, getState) => {
const {routing} = getState();
if (options.id && pushRoute) {
dispatch(push(`/demo/${options.id}${routing.locationBeforeTransitions.search}`));
dispatch(push(`/demo/${options.id}${routing.locationBeforeTransitions?.search ?? ''}`));
}
// if the sample has a kepler.gl config file url we load it
if (options.keplergl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import ReactDOM from 'react-dom';

const WIDTH = 400;
const HEIGHT = 800;
const style = {borther: 0};
const style = {border: 0};

export default class Frame extends Component {
componentDidMount() {
Expand All @@ -34,7 +34,7 @@ export default class Frame extends Component {
}

componentWillUnmount() {
ReactDOM.unmountComponentAtNode(this.root.current.contentDocument);
this.root.current.unmount();
}

root = createRef();
Expand Down
6 changes: 4 additions & 2 deletions examples/demo-app/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
// THE SOFTWARE.

import React from 'react';
import ReactDOM from 'react-dom/client';
import document from 'global/document';
import {Provider} from 'react-redux';
import {browserHistory, Router, Route} from 'react-router';
import {syncHistoryWithStore} from 'react-router-redux';
import {render} from 'react-dom';
import store from './store';
import App from './app';
import {buildAppRoutes} from './utils/routes';
Expand All @@ -42,4 +42,6 @@ const Root = () => (
</Provider>
);

render(<Root />, document.body.appendChild(document.createElement('div')));
const root = ReactDOM.createRoot(document.getElementById('root'));

root.render(<Root />);
1 change: 1 addition & 0 deletions examples/node-app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</style>
</head>
<body>
<div id="root" />
<script src='/bundle.js'></script>
</body>
</html>
4 changes: 2 additions & 2 deletions examples/node-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"global": "^4.3.0",
"@kepler.gl/components": "^3.0.0-alpha.0",
"@kepler.gl/reducers": "^3.0.0-alpha.0",
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-palm": "^3.3.6",
"react-redux": "^7.1.3",
"react-virtualized": "^9.21.0",
Expand Down
6 changes: 4 additions & 2 deletions examples/node-app/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
// THE SOFTWARE.

import React from 'react';
import ReactDOM from 'react-dom/client';
import document from 'global/document';
import {Provider} from 'react-redux';
import {render} from 'react-dom';
import store from './store';
import App from './app';

Expand All @@ -31,4 +31,6 @@ const Root = () => (
</Provider>
);

render(<Root />, document.body.appendChild(document.createElement('div')));
const root = ReactDOM.createRoot(document.getElementById('root'));

root.render(<Root />);
1 change: 1 addition & 0 deletions examples/open-modal/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</style>
</head>
<body>
<div id="root" />
<script src='bundle.js'></script>
</body>
</html>
4 changes: 2 additions & 2 deletions examples/open-modal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"@kepler.gl/actions": "^3.0.0-alpha.0",
"@kepler.gl/components": "^3.0.0-alpha.0",
"@kepler.gl/reducers": "^3.0.0-alpha.0",
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-modal": "^3.1.10",
"react-palm": "^3.3.6",
"react-redux": "^7.1.3",
Expand Down
6 changes: 4 additions & 2 deletions examples/open-modal/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
// THE SOFTWARE.

import React from 'react';
import ReactDOM from 'react-dom/client';
import document from 'global/document';
import {Provider} from 'react-redux';
import {render} from 'react-dom';
import store from './store';
import App from './app';

Expand All @@ -31,4 +31,6 @@ const Root = () => (
</Provider>
);

render(<Root />, document.body.appendChild(document.createElement('div')));
const root = ReactDOM.createRoot(document.getElementById('root'));

root.render(<Root />);
1 change: 1 addition & 0 deletions examples/replace-component/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</style>
</head>
<body>
<div id="root" />
<script src='bundle.js'></script>
</body>
</html>
4 changes: 2 additions & 2 deletions examples/replace-component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"@kepler.gl/reducers": "^3.0.0-alpha.0",
"@kepler.gl/schemas": "^3.0.0-alpha.0",
"@kepler.gl/styles": "^3.0.0-alpha.0",
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-palm": "^3.3.6",
"react-redux": "^7.1.3",
"react-virtualized": "^9.21.0",
Expand Down
Loading

0 comments on commit a0e5db7

Please sign in to comment.