Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
25 lines (22 sloc) 558 Bytes
import React from 'react'
class Async extends React.Component {
constructor (props) {
super(props)
this.state = {
component: props.loader || (() => <div>loading...</div>)
}
}
componentWillMount () {
this.props.component
.then(res => this.setState({ component: res }))
.catch(err => console.error(err))
}
render () {
const Component = this.state.component
return <Component {...this.props.props} />
}
}
export default Async
/*
<Async component={import('react-markdown')} props={{source: content}} />
*/