A component that asynchronously loads a component depending on result of condition.
npm install react-async-branch
if true loads and renders left, if false loads and renders right
component to render if condition is true
component to render if condition is false
component to render while async component loads
additional props will be passed on to rendered component
import React, { Component } from 'react';
import AsyncBranch from 'react-async-branch';
export default class SoCool extends Component {
state = { condition: false };
render() {
return (
<div onClick={() => this.setState({ shouldShow: true })}
<AsyncBranch
condition={this.state.condition}
left={() => import('./left')}
right={() => import('./right')}
otherProp={"nice"}
/>
</div>
);
}
}