Giter Club home page Giter Club logo

adv-react-afternoon's Introduction

Afternoon Practice

(Part 1) presentation / container

step 1 (container)

Build a container component that makes an axios call to the swapi api to retreive specific character by id including the characters homeworld (the homeworld will be a nested axios call)

The Data you should be getting

Character

  • name

  • height

  • mass

  • hair_color

  • skin_color

  • homeworld

    • It should setState with the character data
    • The first call to get the character data only returns url for the homeworld property, you will need to make a nested axios call to get the name of the homeworld
    • setState with all returned data

step 2 (display)

  • Build a Display Component that will only be worried about the ui of you component, you can make either a stateless functional or a class

step 3 (hook it up)

import the Display into the Container component pass props down to the display component

be creative in how you display this components props!

(Part 2) HOC's

step 1 (Build HOC)

Create a higher order component that accepts both a Component and a URL as arguments and returns a new component with the data passed in as a prop.

this is the data you should plan for in your Display Class Component, feel free to add more data from the API (stretch yourself and refer back to the nested call you did in part 1 for inspiration)

character

  • name

  • height

  • mass

  • hair_color

    • Create a function call myHOC that returns an anonymous class
    • declare a function within the anonymous class called fetcher that fetches data using an axios call and the URL passed in to the HOC. setState with the returned data
    • the Anonymous class should return the component that was passed into the HOC with all props and state passed to the returned component as props

step 2 Build a reusable display

Create a Display Class Component that will be wrapped by the HOC.

  • import the HOC into your class component
  • Export Default the Invoked HOC with the display class component passed in as the first argument and the URL of a swapi character as the second argument
  • render the display component in App.js

step 3 Style

style your component beautifully!

(Part 3) Render Props

  • using the lecture code as an example recreate part 2 using render props instead

adv-react-afternoon's People

Contributors

joshborup avatar

Watchers

 avatar  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.