Learning React by Alex Banks

Learning React by Alex Banks

Author:Alex Banks
Language: eng
Format: epub
Publisher: O'Reilly Media
Published: 2017-05-03T04:00:00+00:00


import { render } from 'react-dom' const CountryNames = ({data, selected=""}) => <select className="people-list" defaultValue={selected}> {data.map(({name}, i) => <option key={i} value={name}>{name}</option> )} </select> const CountryDropDown = DataComponent( CountryNames, "https://restcountries.eu/rest/v1/all" ) render( <CountryDropDown selected="United States" />, document.getElementById('react-container') )

The CountryNames component obtains the country names via props. DataComponent handles loading and passing information about each country.

Notice that the CountryNames component also has a selected property. This property should cause the component to select “United States” by default. However, at present, it is not working. We did not pass the properties to the composed component from our HOC.

Let’s modify our HOC to pass any properties that it receives down to the composed component:



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.