Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Unsafe warnings and some improvements. #222

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"presets": [
["es2015", {
"loose": true,
"loose": true
}],
"react",
"react"
],
"plugins": [
"transform-class-properties",
"transform-object-assign",
"transform-object-assign"
],
}
2 changes: 1 addition & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[ignore]
<PROJECT_ROOT>/node_modules/chalk/.*

.*/node_modules/chalk/.*
[include]

[libs]
Expand Down
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
language: node_js
node_js:
- '4'
- '6'
- '8'
- '10'
- '12'
cache: yarn
script: yarn test -- --runInBand --coverage && yarn flow
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class MyComponent extends React.Component {
Bar: null
};

componentWillMount() {
componentDidMount() {
import('./components/Bar').then(Bar => {
this.setState({ Bar: Bar.default });
});
Expand Down
8 changes: 4 additions & 4 deletions example/.babelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"presets": [
"es2015",
"react",
"react"
],
"plugins": [
"dynamic-import-node",
Expand All @@ -11,8 +11,8 @@
"alias": {
"react-loadable": "./src/index.js",
"react-loadable/server": "./src/server.js",
"react-loadable/webpack": "./src/webpack.js",
},
"react-loadable/webpack": "./src/webpack.js"
}
}]
],
]
}
4 changes: 1 addition & 3 deletions example/components/App.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import React from 'react';
import Loadable from 'react-loadable';
import Loading from './Loading';
import delay from '../utils/delay';
import path from 'path';

const LoadableExample = Loadable({
loader: () => import('./Example'),
loading: Loading,
loading: Loading
});

export default function App() {
Expand Down
4 changes: 1 addition & 3 deletions example/components/Example.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import React from 'react';
import Loadable from 'react-loadable';
import Loading from './Loading';
import delay from '../utils/delay';
import path from 'path';

const LoadableNested = Loadable({
loader: () => import('./ExampleNested'),
loading: Loading,
loading: Loading
});

export default function Example() {
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function createLoadableComponent(loadFn, options) {
return init();
}

componentWillMount() {
componentDidMount() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could introduce bugs, why don't you go the safe route and use UNSAFE_componentWillMount for now?

If you really want to go directly to didMount, this._mounted = true would need to move it to the constructor.
Calling retry from the loading component before the mount phase could cause unexpected behaviors with this change, for example.
The _loadModule is probably fine to stay here.

Unfortunately sounds like nobody will ever merge this anyway...

this._mounted = true;
this._loadModule();
}
Expand Down
Loading