I'm using tab navigator and I have a router setting up all off the tabs and I'm using react-native-elements to add a search box into the header of the root tabs:
export const Root = StackNavigator({
Tabs: {
screen: Tabs,
navigationOptions: {
header: <SearchHeader />
}
},
}, {
mode: 'modal',
});
I'm trying to change the placeHolder text in the search bar depending on which tab is focused. Any ideas how I might achieve that?
I was trying to pass down a state from the router but it wasn't working.
return (
<SearchBar
noIcon
containerStyle={{backgroundColor:'#fff'}}
inputStyle={{backgroundColor:'#e3e3e3',}}
lightTheme = {true}
round = {true}
placeholder={this.props.data}
placeholderTextColor = '#000'
/>
);
Please try like this:
And this:
I'm destructuring the props your component receives and set your placeholder as the
data
prop that has been sent to it.Let me know if it works.
Hope it helps.