Complete the code to declare a state variable called count with initial value 0.
const [count, [1]] = useState(0);
The useState hook returns a pair: the current state and a function to update it. The convention is to name the updater as set + state variable name.
Complete the code to pass a prop named title with value 'Hello' to the Greeting component.
<Greeting [1]="Hello" />
Props are passed as attributes to components. Here, the prop name is title.
Fix the error in the code to correctly update the state count by 1 when the button is pressed.
onPress={() => [1](count + 1)}To update state, you must call the updater function returned by useState, here setCount.
Fill both blanks to correctly display a prop called message inside a Text component.
<Text>[1].[2]</Text>
Props are accessed via the props object, so props.message shows the message prop.
Fill all three blanks to create a state variable called text, update it on change, and display it inside a TextInput.
const [[1], [2]] = useState(''); <TextInput value=[1] onChangeText=[2] />
We declare state variable text and updater setText. The TextInput's value is text, and onChangeText calls setText to update it.