Skip to content

Instantly share code, notes, and snippets.

@kmagiera
Created July 24, 2018 11:49
Show Gist options
  • Save kmagiera/f630e5562b1f6fee64aa0509cf0679ee to your computer and use it in GitHub Desktop.
Save kmagiera/f630e5562b1f6fee64aa0509cf0679ee to your computer and use it in GitHub Desktop.
class Composer extends Component {
state = { showAccessory: false };
componentDidMount() {
this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', () =>
this.setState({ showAccessory: true })
);
this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', () =>
this.setState({ showAccessory: false })
);
}
componentWillUnmount() {
this.keyboardDidShowListener.remove();
this.keyboardDidHideListener.remove();
}
render() {
return (
<View>
<EditTextComponent />
(this.state.showAccessory && <AccessoryView />)
</View>
);
}
}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment