In the example above, the CustomButton component is passed a prop of onPress, which then gets passed into the onClick of the button. The
Heres an an example on how to add type checking for event handling in React. This button wouldnt respond to clicks because of the reason above. Event handlers determine what action should be taken when an event occurs. Open the demo to see how the form is rendered. Since the initial state value is an empty string, the input field will also be blank on the initial DOM render. By adding the ref attribute value to the input, we could point to the input that needed to change the value. To get a input value on button click, define a state variable that tracks the input value and add a onChange event handler to it. Similar to how we handled submission with uncontrolled form inputs, well control the submit action by adding an event handler on the