Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default ({ path, match, store, component, getComponent }) => {
const useRouteMatch = useRoute(path);
const [[Component, initialProps], setRoute] = useState([component]);
// `match` is an array from Switch and NestedRouter
const [matches, params] = match || useRouteMatch;
if (!matches) return null;
// When the component is ready to be rendered kickoff the process of
// loading async components if needed and processing and `initialProps`
// That need to be set.
useEffect(async () => {
let c = component, iP = {};
// If component was undefined we should try grabbing an async component.
if (!c && getComponent) {
const m = await getComponent();
c = m.default || m;