| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
In this challenge, you will write the logic for THIS WIDGET.
Study its functionality and also inspect the Console, the Network tab and the Elements tab in Chrome Dev Tools:
❗ Other configurations might work but haven't been tested.
Replicate the functionality and DOM shown in the prototype linked at the top of this README.
Keep your code inside frontend/components/AppFunctional.js and frontend/components/AppClass.js.
The component exposed by AppFunctional.js must be a stateful functional component.
The one in AppClass.js must be a stateful class-based component.
The DOM produced by your components must match exactly the DOM in the prototype:
The coordinates of each square of the grid are as follows:
(1, 1) (2, 1) (3, 1)
(1, 2) (2, 2) (3, 2)
(1, 3) (2, 3) (3, 3)❗ ALL TESTS MUST PASS
Inside AppClass.js and AppFunctional you will find some suggested states and helper functions. Feel free not to use them.
You don't need a complicated structure to track the state of the grid, because we aren't storing any information in the cells.
Imagine that the grid were simply a one-dimension array broken --only visually-- into three rows.
The only component state you need in order to drive the grid is an integer from 0 to 8: the index the "B" is at.
Other pieces of information, like coordinates, can be derived from that index, and don't need a state of their own.
If you want to make life more complicated (or interesting) for yourself, other structures can be used to store the state of the grid:
// A plain array can be used to represent a grid.
// But our App component needn't track the whole array, only the index where the "B" is.
[null, null, null, null, "B", null, null, null, null]
// 2D arrays or matrices can be used to represent a grid, but this is not recommended in this project:
[[null, null, null], [null, "B", null], [null, null, null]]
// A string also could work, but strings in JS are immutable making this approach inconvenient:
"xxxxBxxxx""Product" works hard designing the messages: we must reproduce them faithfully, down to the last comma.
If you start with Functional, don't switch to Class-Based until Functional is passing all its tests (and vice versa).
| Back | FazBrowse Home | New Git URL |