Skip to content

Instantly share code, notes, and snippets.

@javidjamae
Created August 21, 2017 17:20
Show Gist options
  • Save javidjamae/083b92b189525c171509f72c9d42840a to your computer and use it in GitHub Desktop.
Save javidjamae/083b92b189525c171509f72c9d42840a to your computer and use it in GitHub Desktop.
React Native issue with TabNavigator and form autoFocus
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { TabNavigator } from 'react-navigation'
import TheListView from './TheListView'
import TheFormView from './TheFormView'
export default class App extends React.Component {
render() {
return (
<AppNavigator />
);
}
}
const AppNavigator = TabNavigator( {
listView: { screen: TheListView },
formView: { screen: TheFormView }
} )
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
{
"name": "react-navigation-keyboard-dismiss",
"version": "0.0.0",
"description": "Hello Expo!",
"author": null,
"private": true,
"main": "node_modules/expo/AppEntry.js",
"dependencies": {
"expo": "^19.0.0",
"react": "16.0.0-alpha.12",
"react-native": "https://github.com/expo/react-native/archive/sdk-19.0.0.tar.gz",
"react-navigation": "^1.0.0-beta.11"
}
}
import React from 'react'
import { Text, TextInput, View } from 'react-native'
const TheFormView = () => {
return (
<View style={{ marginTop: 50 }}>
<TextInput
autoFocus={ true }
keyboardType="default"
placeholder="Blah"
/>
</View>
)
}
export default TheFormView
import React from 'react'
import { Text, View } from 'react-native'
const TheListView = () => {
return (
<View style={{ marginTop: 50 }}>
<Text>ListView</Text>
</View>
)
}
export default TheListView
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment