react-native tab navigator search box -
i'm using tab navigator , have router setting off tabs , i'm using react-native-elements add search box header of root tabs:
export const root = stacknavigator({ tabs: { screen: tabs, navigationoptions: { header: <searchheader /> } }, }, { mode: 'modal', });
i'm trying change placeholder text in search bar depending on tab focused. ideas how might achieve that?
i trying pass down state router wasn't working.
return ( <searchbar noicon containerstyle={{backgroundcolor:'#fff'}} inputstyle={{backgroundcolor:'#e3e3e3',}} lighttheme = {true} round = {true} placeholder={this.props.data} placeholdertextcolor = '#000' /> );
please try this:
// searchheader.js const searchheader = ({ data }) => { return ( <searchbar noicon containerstyle={{backgroundcolor:'#fff'}} inputstyle={{backgroundcolor:'#e3e3e3',}} lighttheme = {true} round = {true} placeholder={data} placeholdertextcolor = '#000' /> ); }); export default searchheader;
and this:
// navigator export const root = stacknavigator({ tabs: { screen: tabs, navigationoptions: { header: <searchheader data={'tab1'} /> } }, }, { mode: 'modal', });
i'm destructuring props component receives , set placeholder data
prop has been sent it.
let me know if works.
hope helps.
Comments
Post a Comment