Skip to content

Instantly share code, notes, and snippets.

@bogoslavskiy
Created July 8, 2018 21:14
Show Gist options
  • Save bogoslavskiy/c8cc3a1df41a6d5c2da4918e3df8af2a to your computer and use it in GitHub Desktop.
Save bogoslavskiy/c8cc3a1df41a6d5c2da4918e3df8af2a to your computer and use it in GitHub Desktop.
export default class SearchBarProvider extends React.Component {
constructor(props) {
super(props);
[...]
this.state = {
currentTab: null,
canJumpToTab: true,
contextProvider: {
animation: this.searchBarAnimation.animationProps,
addHandlerScroll: this._addHandlerScroll,
_canJumpToTab: this._canJumpToTab
}
};
}
[...]
_canJumpToTab = (canJumpToTab) => this.setState({canJumpToTab});
render() {
return (
<SearchBarContext.Provider value={this.state.contextProvider}>
{this.props.children(this.searchBarAnimation, {
canJumpToTab: this.state.canJumpToTab
})}
</SearchBarContext.Provider>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment