Skip to main content

useBinding

The useBinding hook creates a two-way-binding value that can be passed into views that play a role in updating that value.

function useBinding<T>(initialValue: T): Binding<T>;

Example​

const text = useBinding('');
<TextField text={text} />
<Text>Current Value: {text.value}</Text>

Manually setting the value​

Sometimes you might want to set the value of a binding manually. You can do this by using the setValue method on the binding, or, if your binding is a boolean, you can use the toggle method.

text.setValue('Hi');
showAlert.toggle();