I had the same problem when I built the sample code from Reagent Mastering
The code enclosed the TextInput field in the view with the flexDirection: 'row' function, and the child TextInput field was not available. Only the TextInput border was visible. After playing with some suggestions on this page, I found something that worked.
If the container view has flexDirection: 'row'. Be sure to add flex: 1 to your text box input. The flex image does not seem necessary. As soon as I added flex: 1 to the styles.input sheet, TextInput was available.
The following code works for me:
<View style={globalStyles.COMMON_STYLES.pageContainer}> <View style={styles.search}> <Image style={{height: 30, width: 30}} source={require('../../images/email-white.png')}/> <TextInput style={styles.input} onChangeText={text => this.setState({ searchText: text})} value={this.state.searchText} placeholder={'Search'} placeholderTextColor={globalStyles.MUTED_COLOR}/> </View> </View>
Local styles:
const styles = StyleSheet.create({ input: { flex: 1, height: 35, color: globalStyles.TEXT_COLOR, borderColor: globalStyles.MUTED_COLOR, backgroundColor: globalStyles.BG_COLOR }, search: { borderColor: globalStyles.MUTED_COLOR, flexDirection: 'row', alignItems: 'center', borderRadius: 5, borderWidth: 1,
Global styles (styles / global)
export const COMMON_STYLES = StyleSheet.create({ pageContainer: { backgroundColor: BG_COLOR, flex: 1, marginTop: 0, paddingTop: 20, marginBottom: 48, marginHorizontal: 10, paddingHorizontal: 0 }, text: { color: TEXT_COLOR, fontFamily: 'Helvetica Neue' } });
Hope this helps you guys. It took me a long time to get this simple job.