Git Product home page Git Product logo

quote-maker-react-lab-v-000's Introduction

Redux Put It Together

Objectives

Use the react-redux library and the redux library to build an application with multiple resources.

Overview

In this lab we will be building an application for making quotes. This will include creating a quote and updating the global Redux state.

In our App component we will render the components: QuoteForm & Quotes. We will also need a reducer and actions file for our Quotes.

Quotes Reducer

The quotes reducer should have an initial state of:

[]

But when a Quote is added it should look like. (We will be using the uuid node package for generating ids)

[
  {
    id: '23423424242-42342423424242-fafdb',
    content: 'One Awesome Quote',
    author: 'Luke Ghenco'
  }
]

We will also need to extend out the Quotes Reducer to handle removing quotes, upvoting quotes, and downvoting quotes as well. Check out the test specs for how to build these.

Quotes Actions

Build out several actions as specified in the tests that build Action Creators for add, removing, upvoting and downvoting quotes.

QuoteForm Component

Our Quote form will have a textarea for a quotes content and an input for a quotes author. We will be using component state for updating the inputs so make sure to have a state of { content: '', author: '' } in your QuoteForm constructor. You will make a dispatch action to Redux using an action you will create called addQuote() that will take a quote as an argument and start the reducer process.

Quotes Component

The Quotes Component will render a list of individual QuoteCard components. It needs to be connected to the Redux state so that it can render the quotes. Also make sure to attach the remove, upvote, and downvote actions from the Quotes Actions file to pass down as callback props to the QuoteCard component.

QuoteCard Component

Make sure to connect the callback action props to the the Upvote, Downvote and Delete buttons.

Example App

Here is an image of the example app, of what you are trying to build.

Note

We are using the Node UUID package for this to create random unique ids. Here is the documentation for Node UUID. To use it just import it into your reducer and invoke it

import uuid from 'uuid';

const id = uuid();
console.log(id) // '1fd3234'

View Cooking With Redux on Learn.co and start learning to code for free.

quote-maker-react-lab-v-000's People

Contributors

lukeghenco avatar jeffkatzy avatar beejluig avatar kwebster2 avatar nikymorg avatar

Watchers

James Cloos avatar Dominique De León 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.