I'm a beginner at React and I wanna go step by step using official tutorial: create Tic Tac Toe game. I have a hard time because I learn using functions, not Classes. When i try to implement it i get an error " Line 7:5: 'setSquares' is not defined". I think i need to pass some data from RenderSquare function to handleClick but i don't know how to do it..This is official example provided by React people:
My dumb code:
import Square from './Square';
import { useState } from 'react';
function handleClick(i) {
const squares = squares.slice();
squares[i] = 'X';
setSquares({ squares });
}
function RenderSquare(i) {
const [squares, setSquares] = useState(Array(9).fill(null));
return (
<>
<Square
value={squares[i]}
onClick={() => {
handleClick(i);
}}
/>
;
</>
);
}

handleClickfunction inside theRenderSquarefunctional component. Currently, thehandleClickfunction is outside of scope ofRenderSquare.