Tutorial by Examples

Props are used to transfer data from parent to child component. Props are read only. Child component can only get the props passed from parent using this.props.keyName. Using props one can make his component reusable.
Once setup is completed. Copy the code below to index.android.js or to index.ios.js file to use the props. import React, { Component } from 'react'; import { AppRegistry, Text, View } from 'react-native'; class Greeting extends Component { render() { return ( <Text>Hello {t...
The prop-types package allows you to add runtime type checking to your component that ensures the types of the props passed to the component are correct. For instance, if you don't pass a name or isYummy prop to the component below it will throw an error in development mode. In production mode the p...
defaultProps allows you to set default prop values for your component. In the below example if you do not pass the name props, it will display John otherwise it will display the passed value class Example extends Component { render() { return ( <View> <Text>{this...

Page 1 of 1