Skip to content

Instantly share code, notes, and snippets.

@ryanflorence
Last active December 6, 2016 04:40
Show Gist options
  • Save ryanflorence/b3f949e6df374bfdaef8183c0e995a80 to your computer and use it in GitHub Desktop.
Save ryanflorence/b3f949e6df374bfdaef8183c0e995a80 to your computer and use it in GitHub Desktop.
const {
NativeRouter,
Nav,
StackMatch,
StackScene,
StackTitle,
StackContent
} = 'react-router/native'
const App = () => (
<NativeRouter>
<StackMatch pattern="/" render={(props) => (
<StackScene>
<StackTitle>
<View>Title</View>
</StackTitle>
<StackContent>
<ScrollView>
{stuff.map(item => (
<View>
<Nav to={item.path}>{item.label}</Nav>
</View>
))}
</ScrollView>
</StackContent>
<StackMatch pattern={`${props.pathname}/:id`} render={(props) => (
<StackScene>
<StackTitle transition={FADE}>
<Nav to={props.pathname}>Back</Nav>
{props.id}
</StackTitle>
<StackContent transition={PUSH_FROM_RIGHT}>
<Text>Hello {props.params.id}</Text>
</StackContent>
</StackScene>
)}/>
</StackScene>
)}/>
</NativeRouter>
)
const TwitterStyle = () => (
<NativeRouter>
<StackMatch pattern="/" render={(props) => (
<StackScene>
<StackTitle>
<View>Tweets</View>
</StackTitle>
<StackContent>
<ScrollView>
{stuff.map(item => (
<View>
<Nav to={item.path}>{item.label}</Nav>
</View>
))}
</ScrollView>
</StackContent>
<StackMatch pattern={`${props.pathname}/:tweetId`} component={Tweet}/>
</StackScene>
)}/>
</NativeRouter>
)
const Tweet = (props) => (
<StackScene>
<StackTitle transition={FADE}>
<Nav to={props.pathname}>Back</Nav>
{props.id}
</StackTitle>
<StackContent transition={PUSH_FROM_RIGHT}>
<ScrollView>
{replies.map(item => (
<View>
<Nav to={`${props.path}/${item.id}`}>{item.label}</Nav>
</View>
))}
</ScrollView>
</StackContent>
<StackMatch pattern={`${props.pathname}/:tweetId`} component={Tweet}/>
</StackScene>
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment