Skip to content

Instantly share code, notes, and snippets.

@kmagiera
Created July 26, 2018 11:39
Show Gist options
  • Save kmagiera/f944fc201acef897d8f2775e1c6668bd to your computer and use it in GitHub Desktop.
Save kmagiera/f944fc201acef897d8f2775e1c6668bd 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