UNPKG

storybook-framework-cedarjs

Version:
22 lines (21 loc) 607 B
import { flattenAll } from "@cedarjs/router/dist/react-util"; import { isValidRoute } from "@cedarjs/router/dist/route-validators"; import { replaceParams } from "@cedarjs/router/dist/util"; export * from "@cedarjs/router/dist/index"; const routes = {}; const Router = ({ children }) => { const flatChildArray = flattenAll(children); flatChildArray.forEach((child) => { if (isValidRoute(child)) { const { name, path } = child.props; if (name && path) { routes[name] = (args = {}) => replaceParams(path, args); } } }); return null; }; export { Router, routes };