Search code examples
reactjsreact-nativereact-native-elements

How to put searchbar into header - react-native-elements


i don't know how to put searchbar into header

This is my code

  render() {
    return (
      <View >
        <Header
            centerComponent={<SearchBar></SearchBar>}
        />
      </View>
    );
  } 
}

and looks like this

enter image description here


Solution

  • I think the search bar is already inside the header component, but the search bar's size is bigger than the header height. You can check it with the inspect element in the browser. Try to increase the height of the header

    You can improve the code like this

     <Header centerComponent={<SearchBar/>} />