Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sdd/match-async

react-router v4 Match component replacement that handles code split async components
https://github.com/sdd/match-async

Last synced: 15 days ago
JSON representation

react-router v4 Match component replacement that handles code split async components

Awesome Lists containing this project

README

        

# match-async
react-router v4 Match component replacement that handles code split async components

```javascript
import React, { Component } from 'react';

const asyncComponent = path => class extends React.Component {

componentWillMount() {
if (!this.state) {
require.ensure(path) // or System.import
.then(module => {
this.setState({ Component: module.default })
});
}
}

render() {
const { Component } = this.state;
return Component && ;
}
}

class MatchAsync extends Component {

constructor(props) {
super(props);
const { path } = this.props;
this.state = { component: asyncComponent(path) }
}

render() {
const { path, ...props } = this.props;
const { component } = this.state;
return ;
}
}

const App = () =>




```