feat: add screens prop for nested configs (#308)

Nested configs' names with their configs are now in `screens` property of the route object.
This commit is contained in:
Wojciech Lewicki
2020-01-29 16:21:35 +01:00
committed by osdnk
parent ea66b1a3b8
commit b931ae62df
5 changed files with 193 additions and 108 deletions

View File

@@ -123,18 +123,21 @@ export default function App() {
const { getInitialState } = useLinking(containerRef, {
prefixes: LinkingPrefixes,
config: {
Root: Object.keys(SCREENS).reduce<{ [key: string]: string }>(
(acc, name) => {
// Convert screen names such as SimpleStack to kebab case (simple-stack)
acc[name] = name
.replace(/([A-Z]+)/g, '-$1')
.replace(/^-/, '')
.toLowerCase();
Root: {
path: 'root',
screens: Object.keys(SCREENS).reduce<{ [key: string]: string }>(
(acc, name) => {
// Convert screen names such as SimpleStack to kebab case (simple-stack)
acc[name] = name
.replace(/([A-Z]+)/g, '-$1')
.replace(/^-/, '')
.toLowerCase();
return acc;
},
{}
),
return acc;
},
{}
),
},
},
});