State Management
Main things to know: managing state (locally or via a reducer) is basically identical to React for web. In fact, they both use the react
library, so that shouldn't be surprising. I guess the react
library is just a very generalizable way of representing and tracking changes to a UI.
TextInput
TextInput
React Native provides a primitive TextInput
component for handling text inputs.
Things to note:
There are no default styles, so
TextInput
will appear invisible by default.Like any input in React, you're making it a controlled component. The only difference is that
onChangeText
is youronChange
callback, and it returns the new value of the input.On iOS by default, the first character in your input gets capitalized. To change this, you have the
autoCapitalize
prop.By default, words in your input get autocorrect recommendations. In cases where you don't want that (e.g. inputting a username), you have the
autoCorrect
prop.
Last updated