3
I’m starting to learn react
Activate and I am very doubtful about how to structure my project. I am creating an old game, which has the following configuration:
As you can see, each of the components resides in its own js file.
I’m thinking where is the best place to put the logic of the game, I mean, let’s assume that I have a 3x3 matrix as an attribute of my root component (assuming the component structure is a tree) and the leaves are the empty spaces where we can mark 'X' or 'O'.
How do you communicate the leaves to the root? For example, by clicking on an empty space, I invoke a method putMarkOn (row, col)
, who would be in the game class, for example.
The image shows the structure of the components, what I want to know is ... where to insert the logic, maybe in an external file called Gamelogic?
And how to update the state of the game according to the touch interaction?
Nothing guys? no reply? Anyway thanks.
– Jesley Cáceres Marcelino