You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for the lovely tutorial @beaucarnes . I followed along with your tutorial yesterday evening, typing as you talked, in order to review React and noticed what I believe to be two wee typos/errors:
Issue 1:
Box needs props.id to add an id to the given box element that it is rendering ...
... however, the Grid component is passing the property boxId rather than the property id...
class Grid extends React.Component {
render() {
const width = this.props.cols * 15;
let rowsArr = [];
let boxClass = "";
for (let i = 0; i < this.props.rows; i++) {
for (let j = 0; j < this.props.cols; j ++) {
let boxId = i + "_" + j;
boxClass = this.props.gridFull[i][j] ? "box on" : "box off";
rowsArr.push(
<Box
boxClass = {boxClass}
key = {boxId}
boxId = {boxId}
row = {i}
col = {j}
selectBox = {this.props.selectBox}
/>
);
};
};
return(
<div className="grid" style={{width: width}}>
{rowsArr}
</div>
);
};
};
Issue 2:
Similarly, Grid passes the property key to Box, but the latter doesn't use/need it. In fact it seems that there are no other instances of key in the whole JS file.
Suggestions
Change the following line of Box component's render method:
id = {this.props.id}
to the following, which should keep things clearer and more consistent (e.g., as compared to boxClass):
id = {this.props.boxId}
and remove the following line from Grid:
key={boxId}
Thanks again Beau!
The text was updated successfully, but these errors were encountered:
Hiya,
Thanks for the lovely tutorial @beaucarnes . I followed along with your tutorial yesterday evening, typing as you talked, in order to review React and noticed what I believe to be two wee typos/errors:
Issue 1:
Box needs
props.id
to add anid
to the given box element that it is rendering ...... however, the Grid component is passing the property
boxId
rather than the propertyid
...Issue 2:
Similarly, Grid passes the property
key
to Box, but the latter doesn't use/need it. In fact it seems that there are no other instances ofkey
in the whole JS file.Suggestions
Change the following line of Box component's render method:
to the following, which should keep things clearer and more consistent (e.g., as compared to
boxClass
):and remove the following line from Grid:
Thanks again Beau!
The text was updated successfully, but these errors were encountered: