Giter VIP home page Giter VIP logo

react-ii-mini-sprint's Introduction

React-II-Mini

Link to video

Topics

Lesson Battle Plan

  • Steps to get up and running

    • Step 1: fork and clone this project and cd into it.
    • Step 2: run npm install create-react-app -g to install CRA locally.
    • Step 3: run create-react-app react-friends.
    • Step 4: move the people.js file from this repo into the src directory inside of your new react-friends project.
    • Step 5: cd into react-friends and run npm start or yarn start and navigate to localhost:3000.
  • App/PeopleList Set Up

    • Step 1: inside of App.js create your constructor function, (don't forget to super()) and add a state object to it. Inside that state object define an array called People.
    • Step 2: import people data in like so: import { people } from './people.js (if you haven't included people in your src directory this wont work); _ Step 3: create a method called componentDidMount and set the people data on state.
    • Step 4: create your PeopleList as a function component and import it in as: import {PeopleList} from './PeopleList'.
    • Step 5: pass your People data down to PeopleList and render out the People List <PeopleList people={this.state.People} />.
    • Step 6: for each person in PeopleList render out the first_name and last_name and email.
    • Step 7: Go to town styling your components!
  • Styling Components

    • Step 1: create a file called PeopleList.css and go to town styling! Try and center each person on the screen.
    • Step 2: import PeopleList styles into PeopleList.js as `import './PeopleList.css'; to grant you access to the className references.
      • Hint: Delete the styles in the app.css and index.css files and do it on your own! Make things look pretty!
    componentDidMount(){ 
     this.setState({People: people});
    }
    

Examples

Your App.JS component Should look similar to this:

import React, { Component } from 'react';
import './App.css';
import { people } from './people';
import { PeopleList } from './PeopleList';

class App extends Component {
  constructor() {
    super();
    this.state = {
      People: [],
    };
  }

  componentDidMount() {
    this.setState({People: people});
  }

  render() {
    return (
      <div className="App">
        <h1>Hello React App</h1>
        <PeopleList people={this.state.People} /> 
      </div>
    );
  }
}

export default App;

Your PeopleList.JS component Should look similar to this:

import React from 'react';
import Person from './Person';
import './PeopleList.css';

export const PeopleList = (props) => {
  return (
    <div className="People-Wrapper">
      {props.people.map((person => {
        return (
            <div>
              <h4>{person.first_name}</h4>
              <h4>{person.last_name}</h4>
              <div>{person.email}</div>
            </div> 
          )
      }))}
    </div>
  )
};

react-ii-mini-sprint's People

Contributors

ceylonsullen avatar seanchen1991 avatar

Watchers

James Cloos 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.