Skip to content
Closed
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
2 changes: 1 addition & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[ignore]
<PROJECT_ROOT>/node_modules/chalk/.*
.*/node_modules/chalk/.*

[include]

Expand Down
5 changes: 2 additions & 3 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'
cache: yarn
cache:
yarn: false
script: yarn test -- --runInBand --coverage && yarn flow
17 changes: 8 additions & 9 deletions __tests__/test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const path = require('path');
const React = require('react');
const renderer = require('react-test-renderer');
const Loadable = require('../src');
Expand Down Expand Up @@ -34,7 +33,7 @@ function MyComponent(props) {
afterEach(async () => {
try {
await Loadable.preloadAll();
} catch (err) {}
} catch (err) { }
});

test('loading success', async () => {
Expand Down Expand Up @@ -140,7 +139,7 @@ test('render', async () => {
loader: createLoader(400, () => ({ MyComponent })),
loading: MyLoadingComponent,
render(loaded, props) {
return <loaded.MyComponent {...props}/>;
return <loaded.MyComponent {...props} />;
}
});
let component = renderer.create(<LoadableMyComponent prop="baz" />);
Expand All @@ -161,8 +160,8 @@ test('loadable map success', async () => {
render(loaded, props) {
return (
<div>
<loaded.a.MyComponent {...props}/>
<loaded.b.MyComponent {...props}/>
<loaded.a.MyComponent {...props} />
<loaded.b.MyComponent {...props} />
</div>
);
}
Expand All @@ -186,8 +185,8 @@ test('loadable map error', async () => {
render(loaded, props) {
return (
<div>
<loaded.a.MyComponent {...props}/>
<loaded.b.MyComponent {...props}/>
<loaded.a.MyComponent {...props} />
<loaded.b.MyComponent {...props} />
</div>
);
}
Expand Down Expand Up @@ -272,9 +271,9 @@ describe('preloadReady', () => {
delay: 0,
timeout: 200,
});

let loadingComponent = renderer.create(<LoadableMyComponent prop="foo" />);

expect(loadingComponent.toJSON()).toMatchSnapshot(); // loading
});
});
4 changes: 1 addition & 3 deletions example/components/App.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
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,
});

export default function App() {
return <LoadableExample/>;
return <LoadableExample />;
}
4 changes: 1 addition & 3 deletions example/components/Example.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
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'),
Expand All @@ -13,7 +11,7 @@ export default function Example() {
return (
<div>
<h1>Hello from a loadable component</h1>
<LoadableNested/>
<LoadableNested />
</div>
);
}
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() {
UNSAFE_componentWillMount() {
this._mounted = true;
this._loadModule();
}
Expand Down
Loading