Last active
August 14, 2020 14:52
-
-
Save taion/bf09d305dbe547adf0600d103440bbd7 to your computer and use it in GitHub Desktop.
Router strawman
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// You can imagine some shorthand for generating this given a component and | |
// a Relay query. | |
import React from 'react'; | |
import getFoo from './getFoo'; | |
import lazyComponent from './lazyComponent'; | |
export default function fooEntrypoint({ fooId }) { | |
const Component = lazyComponent(import('Foo')); | |
const data = getFoo(fooId); | |
return function Foo({ children }) { | |
return <Component data={data}>{children}</Component>; | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import appEntrypoint from './app.entrypoint'; | |
import fooEntrypoint from './foo.entrypoint'; | |
export default { | |
entrypoints: { | |
App: () => ({ | |
entrypoint: appEntrypoint, | |
}), | |
Foo: ({ id }) => ({ | |
entrypoint: fooEntrypoint, | |
params: { fooId: id }, | |
}), | |
}, | |
render: ({ App, Foo }) => <App><Foo>Content</Foo></App>, | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This could be auto-generated, maybe? | |
import rootRoute from './root.route'; | |
export default { | |
'/': rootRoute, | |
'/foo/:id': () => import('./foo.route'), | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment