Technologies: HTML, CSS, JS, React, react-router, react context.
Enough with the landing pages and single view projects, it is time to build our first web app.
This is a collaborative project, the class will be separated in groups and each will create a piece of a multi-view website.
Do not clone this repository.
git clone
command.This is the repository you need to clone and open:
1https://github.com/4GeeksAcademy/react-hello-webapp
👉 Please follow these steps on how to start a coding project.
If working locally, type the following command to clone from your command line: git clone https://github.com/4GeeksAcademy/react-hello-webapp
.
Invite the other students as collaborators.
All the students clone the repository.
Divide the project workload into pieces and each group starts working on its piece, 2 or max 3 people per group.
Install the dependencies $ npm install
Start the WebPack development server: $ npm run start
Done!
Each group will have to create the corresponding view component with dummy content (initially) and as many "smaller" components as needed.
Note: Think DRY (Don't repeat yourself) and declare only one component and use props
to handle different content.
Each group must use the Consumer given by the instructor in order to use the store to fill the content of the pieces:
The store
structure:
1store = { 2 posts:[ 3 { 4 title: 'This is a World Post', 5 content: 'Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.', 6 date: 'Oct 15', 7 tags: ['World'], 8 author: 'Denise A', 9 image: 'https://storage.googleapis.com/breathecode-asset-images/cc58af739f10c2322e6acfebfc2cbc71fe81556c22fcf556e908542c2f4d4001.png', 10 thumbnail: 'https://media.takealot.com/covers_tsins/50045787/50045787-1-listgrid.jpg' 11 }, 12 ... 13 ], 14 15 products:[ 16 { 17 name: 'Vintage Phone', 18 image: 'https://storage.googleapis.com/breathecode-asset-images/26004b86a7c1ff2915ca43328d8774ef6690cfa139ce64fb05cf4a73838b07d5.jpg?auto=compress&cs=tinysrgb&h=500&w=500', 19 price: 300.67, 20 description: 'Embrace nostagia with a brand new flip phone' 21 }, 22 ... 23 ], 24 25 session:{ 26 username:'Rigo', 27 email: 'rigocodes@gmail.com', 28 loggedIn: false 29 }, 30 31 cart:[ 32 { 33 name: 'Polaroid Camera', 34 image: 'https://storage.googleapis.com/breathecode-asset-images/55733ee07ada7ebeab108fe67331d409a468e92cf805b66d8ede2d3054ed46a6.jpeg?auto=compress&cs=tinysrgb&h=500&w=500', 35 price: 129.99, 36 description: 'Get instant photos' 37 }, 38 ... 39 ] 40};
In order to have access to the global data, you'll have to import the context's main file:
1import {Context} from '/path/to/store/appContext.jsx'; 2 3const MyView = () => { 4 const { actions, store } = useContext(Context); 5 //Then use the Consumer anywhere on the component 6 return (<span> hello, {store.session.username} </span>); 7}
Hint: you can see an example of the Context.Consumer
in action at:
1demo.jsx 2 - demoList.jsx 3 - demoProducts.jsx
In order to prepare better for completing this exercises, we suggest the following materials