GithubHelp home page GithubHelp logo

deoliveirajuan / lab-react-ironbeers-lifecycle Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tinycarol/lab-react-ironbeers-lifecycle

0.0 0.0 0.0 349 KB

Module 3 lab for react lifecycle

JavaScript 45.45% CSS 16.22% HTML 38.33%

lab-react-ironbeers-lifecycle's Introduction

logo_ironhack_blue 7

LAB | React IronBeersLifecycle

Since beer is one of the most consumed drinks between Ironhackers ๐Ÿป, our mission here is to create an app to showcase some of the best-handcrafted beers. Our end goal is creating something like this:

Setup

  • Fork this repo
  • Clone the forked repo
$ cd lab-react-ironbeers
$ npm install
$ npm start

Submission

  • Upon completion, run the following commands:

    git add .
    git commit -m "done"
    git push origin master
    
  • Create Pull Request so your TAs can check up your work.

Introduction

We will be building a React app so the API (server) needs to be built somewhere for us, right? You are completely right, it's deployed on heroku and the root fo the API is: https://ih-beers-api2.herokuapp.com/beers.

There are multiple endpoints in this API, but we're only going to be using the following one:

Method Endpoint Response (200) Action
GET /beers [beers] Get all the beers from the DB

The IronBeersLifecycle project will use this enpdoint to list the existing beers.

Instructions

โ— Shoot for the stars! Focus on mobile first design! This is a bonus, so it's up to you. ๐Ÿ‘

Iteration 1 | Empty state

To get started, we need to model our app, starting by creating a BeersList component.

This component should initially just display a Loading... text. The reason is that, since the beers info comes from the API which can take some time to reply, we must display something while the user waits. So let's do just that!

Iteration 2 | Getting the beers

Once we have that out of the way, we can focus on getting and diplaying the beers!

The list of beers will come from the API, specifically from the beers endpont: https://ih-beers-api2.herokuapp.com/beers. We need axios for this! So the first step is to install it:

npm install axios

We know that API calls shouldn't be performed on the constructor or render method, but luckily we just found out about the lifecycle of a React component. We only want the beers list to be loaded on the first render, so we should use the componentDidMount lifecycle method to get the beers.

๐Ÿ•ต๏ธ Hint: The array of beers is an array of objects. We strongly advise you to open the URL to see the response format in the browser!

You can start by dysplaying just the name of the beer.

The first time you call the API, it might take a bit to respond. It's hosted on Heroku, and it goes to sleep after 30 minutes, you know! ๐Ÿ˜‰

Iteration 3ย | Make it pretty

For this iteration, we want to expand the information we show. You should display the following from each of the beers:

  • image
  • name
  • tagline
  • contributed_by

Remember to think in React! You should create a Beer component for this ๐Ÿ˜‰

We are done! ๐Ÿ†

Awesome! Grab a beer (if you're not underage ๐Ÿ˜‰ )! Now you are a React Warrior, keep training to become the Ninja!

Happy coding! ๐Ÿ’™

lab-react-ironbeers-lifecycle's People

Contributors

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