Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import createBrowserRouter from 'found/lib/createBrowserRouter';
import React from 'react';
import { hot } from 'react-hot-loader';
import routeConfig from './routeConfig';
const BrowserRouter = createBrowserRouter({
routeConfig,
/* eslint-disable react/prop-types */
renderError: ({ error }) => (
<div>{error.status === 404 ? 'Not found' : 'Error'}</div>
),
/* eslint-enable react/prop-types */
});
export default hot(module)(BrowserRouter);
<ul>
Main
<ul>
Foo
Bar
</ul>
</ul>
{children}
);
}
App.propTypes = propTypes;
const BrowserRouter = createBrowserRouter({
routeConfig: [
{
path: '/',
Component: App,
children: [
{
Component: () => <div>Main</div>,
},
{
path: 'foo',
getComponent: () =>
new Promise(resolve => {
setTimeout(resolve, 1000, () => <div>Foo</div>);
}),
},
{
<button type="button">
Yes
</button>
<button type="button">
No
</button>
)}
);
}
}
Main.propTypes = mainPropTypes;
const BrowserRouter = createBrowserRouter({
historyOptions: { useBeforeUnload: true },
routeConfig: [
{
path: '/',
Component: App,
children: [
{
Component: Main,
},
{
path: 'other',
Component: () => <div>Other</div>,
},
],
},
<ul>
Foo
Bar (async)
Baz (redirects to Foo)
Qux (missing)
</ul>
{children}
);
}
App.propTypes = propTypes;
const BrowserRouter = createBrowserRouter({
routeConfig: makeRouteConfig(
<div>Main</div>} />
<div>Foo</div>} />
new Promise(resolve => {
setTimeout(resolve, 1000, ({ data }) => <div>{data}</div>);
})
}
getData={() =>
new Promise(resolve => {
setTimeout(resolve, 1000, 'Bar');
})
}
<ul>
Foo
Bar (async)
Baz (redirects to Foo)
Qux (missing)
</ul>
{children}
);
}
App.propTypes = propTypes;
const BrowserRouter = createBrowserRouter({
routeConfig: [
{
path: '/',
Component: App,
children: [
{
Component: () => <div>Main</div>,
},
{
path: 'foo',
Component: () => <div>Foo</div>,
},
{
path: 'bar',
getComponent: () =>
new Promise(resolve => {