Skip to content

Instantly share code, notes, and snippets.

View meksiabdou's full-sized avatar
🏠
Working from home

Meksi Abdennour meksiabdou

🏠
Working from home
View GitHub Profile
@TyrealGray
TyrealGray / Lifecycle in React Native Component.md
Last active November 12, 2018 17:18
Lifecycle in React Native Component

Lifecycle in React Native Component

When we are developing our app, there are some features we always need to add, e.g. ListView components only refresh when the data in listItem is changed, initializing data before render function but not in the constructor function…

React Native component has already been implemented with many native optimization for us, but those features above are not. To do that, we need to override lifecycle function in React Native component.

The Component Lifecycle API

First of all, this is the official site docs about the API we could use:https://facebook.github.io/react/docs/react-component.html#the-component-lifecycle

The order of lifecycle should be: constructor() -> componentWillMount() -> render() -> componentDidMount() -> [ runtime loop ] -> componentWillUnmount()