I’m still experimenting with react architecture in order to build my framework. So bare in mind that I’m kind of new to all these concepts.
I have a part of my code where I created two class based components:
<LayoutFrontendMain>
</LayoutFrontendMain>
And
<FrontendCategoriesListing>
</FrontendCategoriesListing>
Next, I managed to display the FrontendCategoriesListing component in the right place of the LayoutFrontendMain component, passing the component as props, like so:
<LayoutFrontendMain cphBody={<FrontendCategoriesListing />}>
</LayoutFrontendMain>
So far, so good. The content of FrontendCategoriesListing is appearing in the right place of the LayoutFrontendMain component, just as I wanted.
The problem is that I have a very simple method (for now), in LayoutFrontendMain that changes state in itself. Something like so:
LayoutFrontendMain:
changeState()
{
this.setState({
titleCurrent: "new current title"
});
}
Can I access this method and change the state in the component with the component I passed as a prop? Preferably, passing a string to change the state. Couldn’t find an example like this, anywhere.