I have a main component that gets rendered on the "/" route (which is set up on index.js). There's a common search bar in App that's rendered above/outside of it's own child routes. Basically I want this search bar to be common across the application. The search bar updates a property on App state whenever there's a change. It works OK in all routes except for the fact that every time I type in the search bar in a child route, App along with the current child route component gets re-rendered. How can I prevent this re-rendering, since there are no prop changes and no need to re-render the child component?
// App.js
render()
...
<SearchBar
className={classes.searchbar}
value={(this.state.query && decodeURI(this.state.query)) || ''}
onChange={this.handleQueryChange}
inputRef={(el) => el && el.focus()}
onRequestSearch={this.handleSearch}
style={{
margin: '0 auto',
maxWidth: 800
}}
/>
...
<Route
path="/:projectName/admin"
render={(props) => (
<Admin
{...commonProps}
handleError={this.handleError}
updateIsLoadingResults={this.updateIsLoadingResults}
/>
)}
/>