This course will be retired on December 9, 2018.
Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Event Handling with React Native1:47 with Brandy Morgan
A core piece of any application is event handling. This video will cover how to tell your application when to perform a specific piece of functionality in response to the user.
- React events are named using camelCase, rather than lowercase.
- With JSX you pass a function as the event handler, rather than a string.
A core piece of any application is event handling.
Events essentially tell your application when to perform a specific
piece of functionality in response to the user.
Different react native components are equipped with different types of
action handlers that you can pass a call back function to.
These functions would be responsible for
carrying out the intended functionality expected by the user action.
Example events are the onPress,
which is generated by buttons or touchable highlights.
onChangeText which is generated by a text input, onLongPress which
allows you to detect when a user presses and hold a view for a set amount of time.
Components have a lifecycle.
They are instantiated, created, mounted, rendered to the screen.
Eventually updated, re-rendered, unmounted,
removed from the screen and destroyed, garbage collected.
The lifecycle helps manage the complexity of different platform APIs, IOS and
Android by providing a simple, consistent abstraction layer.
The lifecycle allows you to optionally execute custom code at each step for
more fine grain control.
A high level component lifecycle example, whenever the component is re-rendered
to the view for the first time, this is called mounting.
componentWillMount, a component is about to be placed in the view.
componentDidMount, a component has been placed in the view.
Whenever a component is removed from the view, this is called unmounting.
componentWillUnmount, a component is about to be removed from the view.
You need to sign up for Treehouse in order to download course files.Sign up