Coder Social home page Coder Social logo

3.1.2's Introduction

React-Friends

  • This mini project is designed to get you used to how components can be built around data that is a bit more complicated
  • Sometimes Data doesn't just necessarily exist on a component's state.
  • We're going to be using an external data source (although it'll be found locally in our project) from a file in our app called people.js.
  • Your goal is to use componentDidMount to set that data on the state of the component you'll be building, and consuming it within a render function.

App.js set up

  • Inside of App.js create your constructor function, (don't forget to super() Remember The CCR Steps) and add a state object to it. Inside that state object define an array called People.
  • Import people data in like so: import { people } from './people.js (if you haven't included people in your src directory this wont work);
  • Create a method called componentDidMount and set the people data on state.
  componentDidMount(){
   this.setState({ people: people });
  }

PeopleList.js set up

  • Create your PeopleList as a function component and got back to App.js and import it in as: import { PeopleList } from './PeopleList'.
  • Pass your People data down to PeopleList and render out the People List <PeopleList people={this.state.people} />.
  • For each person in PeopleList render out the first_name and last_name and email.

3.1.2's People

Contributors

maxwellchrist avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.