March 2019
Beginner to intermediate
324 pages
7h 17m
English
The next obvious step is to set our state object with a list of product cards. To set data in a React state object, we must use a method called setState(), which belongs to our component object. Here is an example of us setting our state object with the information of two product cards:
this.setState({ cards: [{ "id" : 1, "img" : "img/strings.png", "imgalt":"string", "desc":"A very authentic and beautiful instrument!!", "price" : 100.0, "productname" : "Strings" }, { "id" : 2, "img" : "img/redguitar.jpeg", "imgalt":"redg", "desc":"A really cool red guitar that can produce super cool music!!", "price" : 299.0, "productname" : "Red Guitar" }]});
The render() method of our CardContainer component will need to change to look ...
Read now
Unlock full access