Use map to Create React Components from Arrays of Data

Share this video with your friends

Send Tweet

React components can be dynamically generated based on a dataset. This lesson will show you how to do just that by mapping over the state.data object.

Huy Tran
Huy Tran
~ 9 years ago

The video is so good. But can you please tell me when and what benefits to use stateless Component. Is this the same with this code ? ( I bet it is because I tried it )

class Person extends React.Component{ render(){ return ( <tr> <td>{this.props.data.id}</td> <td>{this.props.data.name}</td> </tr> ); } }

Thank you !

frantzyy
frantzyy
~ 7 years ago

when using fetch I get a failed to load error due to the api has been "blocked by CORS". I tired setting mode: 'no-cors' but still no joy. Should I be running webpack server in a different mode or should I be trying to configure the fetch?

RESOLVED: by using the https endpoint instead of http.

Lokesh Sanapalli
Lokesh Sanapalli
~ 6 years ago

Getting below error, even though using no-cors mode. Adding Access-Control-Allow-Origin: * doesn't work too. Anyone has same problem ??

SyntaxError: Unexpected end of input
    at App.js:43
App.js:40 Cross-Origin Read Blocking (CORB) blocked cross-origin response https://swapi.co/api/people/?format=json with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.