If someone code a function-based component in react native, the component calls the props(no matter the param's name) as the first parameter.
useState(initValue)
: Returns an array, whose first entry is the name of a state, and the second one is the name of a function which will be used to change the state.useEffect(callbackFunction, [array]){}
: A hook that works the same as componentDidMount
and componentDidUpdate
in class-based components. One component may contain multiple useEffect
hooks, and they will operate in an order. By writing the name of state in the [array]
part, one can easily control the states at which the useEffect hook is going to react. If nothing is written like []
, the hook works as same as componentDidMount
.return(callback function)
in a useEffect
hook works the same as componentWillUnmount
in class-based components. It works as a clean-up phase of an update of a component.