GithubHelp home page GithubHelp logo

hathaway-shan / react-module-8 Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 165 KB

Practice using React Router by using the useParams hook to change the background color the page running different routes.

Home Page: https://glowing-pudding-60e988.netlify.app/

JavaScript 52.74% HTML 30.68% CSS 16.58%
react react-router useparams-hook

react-module-8's Introduction

Alchemy React Base Template

This project was bootstrapped with Create React App.

Use this template for all your "from scratch" deliverables. To start, simply run

  • npm install
  • npm start

Available Scripts

In the project directory, you can run:

npm start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

npm test

Launches the test runner in the interactive watch mode.
See the section about running tests for more information.

The Golden Rule:

🦸 πŸ¦Έβ€β™‚οΈ Stop starting and start finishing. 🏁

If you work on more than one feature at a time, you are guaranteed to multiply your bugs and your anxiety.

Making a plan in React

  1. Make a drawing of your app. Simple "wireframes"
  2. Component Tree
    1. Look at the drawing and break it down into Components. Label these Components explicitly (i.e., DogList, etc)
    2. Draw a hierarchy (or tree) of components, describing which components are parents and which are children
    3. Looking at the drawing, make a list of your app's features. What should a user "be able to do" with this app?
    4. Now look at your component tree: which components "go with" which features? Draw lines and make these connections explicitly.
  3. State
    1. Look back at the drawing and your list of features and imagine using the app. What state do you need to track?
    2. For each piece of state, ask: "When does it change?" If the answer is, "never", then it is not state.
    3. Similarly, find all the 'events' (user clicks, form submit, on load etc) in your app. Ask one by one, "What state changes?" for each of these events. (This should feel like the the inverse of the previous step.)
    4. Think about how to validate each of your state changes. How will I know if state changed in response to this event? (Hint: react dev tools or console.log usually helps here.)
  4. Data flow
    1. Look at your hierarchy and ask: which components need access to which state? Another way to ask this is: for each component, what does this component need to "do its job?". This list becomes the "props" of the component.
    2. If a child needs state from a parent, you will need to pass props. What will you name these props?
    3. Notice especially if two siblings need the same state: if so, you need a callback (i.e., debit card).
  5. Pick one feature from your list and build it out. Start with its parentmost component, and work down the component chain. Do not build another feature until this one is finished (and you can prove that it is finished by validating state change).

Additional considerations

  • Is any of your state redundant? For example, if you're tracking wins, losses, and total, you can probably get rid of losses state, and calculate it as total - wins.
  • Where should each piece of state live? How are you going to get data from where it lives to where it needs to be?

react-module-8's People

Contributors

hathaway-shan 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.