The purpose of this exercise is to understand a react app architecture, whether it uses redux or built-in React tools (context and hooks).
For a single person, use a VS code liveshare session (or equivalent) and let the learner go step by step while questioning the decisions taken. Of course, re-orient him/her when the decision is not right by explaining why and giving hints on the right direction to take.
- node >= 11
- yarn 1.*
- vscode with liveshare
- prettier / eslint extensions
git clone https://github.com/generous-folks/react-retro-workshop
yarn && yarn start
- Identify the html structure
You may use https://wireframe.cc/ to help visualize the DOM elements
- Identify the react component structure from the html one, list them
You may use https://wireframe.cc/ to help visualize the react elements
- List the methods you will need
- List the states you will need
- Virtually assign the state and methods to the components you listed earlier
- With Context, how would you architecture your app so every components access what it needs and nothing else (if possible)
- With Redux, how would you architecture your app so every components access what it needs and nothing else (if possible)
- Create your directory structure and file structure
- Create your routes
- Create your shared components
- create a basic html (jsx) markup for your pages
- Create your store
- create your modules (features reflecting the business)
- access the store and methods in your components and identify the pitfalls (redux or context)
- Style it with material ui to gain time
- 🎉
To gain time, some tools and dependencies are already in place :
- react
- prop-types
- react-router
- connected-react-router
- redux
- react-redux
- redux-thunk
- @material-ui/core
- @material-ui/icons
- @material-ui/styles
- eslint
- prettier
- redux-devtools
- react-devtools
To build this app, we use an API that returns articles.
The methods to fetch the API are already coded in src/utils/api.utils.js
The data model:
// ArticlesType represents the articles collection in the database
type ArticlesType []map[string]interface{}
// ArticleFieldsType defines the structure of the fields in an article from the articles collection.
type ArticleFieldsType struct {
ID string `firestore:"id"`
Name string `firestore:"name"`
Price float64 `firestore:"price"`
Type string `firestore:"type"`
Year string `firestore:"year"`
Image string `firestore:"image"`
Description string `firestore:"description"`
Slug string `firestore:"slug"`
}
The getArticles
method will return the articles collection as body of the GET
request.
/home
- List of articles
- Cart on the side
/article/${id}
- article card
- Cart on the side
- return home cta
/about
- return home cta
- AppBar with nav menu
- Empty Card with a checkout button by default
- List of added items with delete/minus button (you can add the same item and increment its count from the
add to cart
button)
- A card with:
- an image
- a title
- a description
- an
add to cart
cta - a
view
(article) cta
- Redux: https://codesandbox.io/s/9on71rvnyo
- Material-UI:
- React Context/Reducer: https://kentcdodds.com/blog/how-to-use-react-context-effectively