O'Reilly logo

React Native By Example by Richard Kho

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Basic ExpandableCell implementation

This is how we can start building ExpandableCell:

// Tasks/app/components/ExpandableCell/index.js import React, { Component, PropTypes } from 'react'; import {   LayoutAnimation,   Text,   TouchableHighlight,   View } from 'react-native'; import styles from './styles'; export default class ExpandableCell extends Component {

This sets the title as an expected string PropTypes for the component:

  static propTypes = {     title: PropTypes.string.isRequired   } 

Now we track a Boolean named expanded in the component state. By default, our child components should not be visible:

  constructor (props) {     super (props);     this.state = {       expanded: false     }   } 

Set the LayoutAnimation style for whenever this component ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required