Skip to content

Instantly share code, notes, and snippets.

@jd20
Created December 25, 2017 09:55
Show Gist options
  • Save jd20/b05fd748528c35a592fdfa6daa24a6af to your computer and use it in GitHub Desktop.
Save jd20/b05fd748528c35a592fdfa6daa24a6af to your computer and use it in GitHub Desktop.
Shadow view with tag warnings
import React, { Component } from 'react';
import { Button, Text, TextInput, View } from 'react-native'
import { StackNavigator, NavigationActions } from 'react-navigation'
class MainScreen extends React.Component {
componentWillMount () {
this.props.navigation.setParams({asdf: 1234})
}
render () {
const { navigation } = this.props
return (
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
<Text style={{fontSize: 36}}>Main</Text>
<Button title='Login' onPress={() => navigation.navigate('Login')} />
</View>
)
}
}
const LoginScreen = (props) => {
return (
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
<Text style={{fontSize: 36}}>Login</Text>
<TextInput style={{width: 200, borderWidth: 1}} value='Hello' />
<TextInput style={{width: 200, borderWidth: 1}} value='World' />
<Button title='Done' onPress={() => {
props.navigation.dispatch(NavigationActions.reset({
index: 0,
actions: [NavigationActions.navigate({ routeName: 'Main' })]
}))
}} />
</View>
)
}
const ModalStack = StackNavigator({
Main: { screen: MainScreen },
Login: { screen: LoginScreen },
})
export default class App extends Component<{}> {
render() {
return <ModalStack />
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment