prettier applied to all files in src/
This commit is contained in:
1 parent
433bb219b0
commit
fb7c229b43
69 files changed
+1128
-1116
No files matched your search
@@ -4,34 +4,34 @@
|
||||
* Link: https://serverless-stack.com/chapters/code-splitting-in-create-react-app.html
|
||||
*/
|
||||
|
||||
import React, { Component } from 'react'
|
||||
import React, { Component } from 'react';
|
||||
|
||||
export default function asyncComponent(importComponent) {
|
||||
class AsyncComponent extends Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
component: null,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
// Add dynamically loaded component to state
|
||||
const { default: component } = await importComponent()
|
||||
const { default: component } = await importComponent();
|
||||
|
||||
this.setState({
|
||||
component: component,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const C = this.state.component
|
||||
const C = this.state.component;
|
||||
|
||||
// Render the loaded component, or null
|
||||
return C ? <C {...this.props} /> : null
|
||||
return C ? <C {...this.props} /> : null;
|
||||
}
|
||||
}
|
||||
|
||||
return AsyncComponent
|
||||
return AsyncComponent;
|
||||
}
|
||||
Reference in new issue
Block a user