Learning React by Alex Banks and Eve Porcello

Learning React by Alex Banks and Eve Porcello

Author:Alex Banks and Eve Porcello
Language: eng
Format: mobi, pdf
Publisher: O'Reilly Media, Inc.
Published: 2017-05-03T04:00:00+00:00


Example 7-3. ./components/hoc/Expandable.js

import { Component } from 'react' const Expandable = ComposedComponent => class Expandable extends Component { constructor(props) { super(props) const collapsed = (props.hidden && props.hidden === true) ? true : false this.state = {collapsed} this.expandCollapse = this.expandCollapse.bind(this) } expandCollapse() { let collapsed = !this.state.collapsed this.setState({collapsed}) } render() { return <ComposedComponent expandCollapse={this.expandCollapse} {...this.state} {...this.props} /> } }



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.