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
Extracting part of your render into a function can be useful if you've got a huge render method that's gotten confusing, but in this case your renderCell() function just returns a React component. Since a component is effectively already a function you might as well skip the middleman and use it directly:
It's also probably more readable to extract a big render into an actual component rather than a normal function, since it'll fit in better with the rest of the JSX:
constCellList=({ i })=>(<CellclassName={`cell${i}`}value={this.state.cells[i]}onClick={()=>this.handleClick(i)}style={{backgroundColor: this.state.colours[i]}}/>)
This whole thing would probably be solved by using array.map((value, i) => <Cell ... />) though since it would make your render method a lot smaller.
The text was updated successfully, but these errors were encountered:
Extracting part of your render into a function can be useful if you've got a huge render method that's gotten confusing, but in this case your
renderCell()
function just returns a React component. Since a component is effectively already a function you might as well skip the middleman and use it directly:It's also probably more readable to extract a big render into an actual component rather than a normal function, since it'll fit in better with the rest of the JSX:
This whole thing would probably be solved by using
array.map((value, i) => <Cell ... />)
though since it would make your render method a lot smaller.The text was updated successfully, but these errors were encountered: