I have components App
, TextBox
, and Toolbar
.
TextBox is draftjs component, so it is basically textarea with a lot of features. Toolbar
controls TextBox
.
//render in App
return (
...
<TextBox changeTextBox={this.changeTextBox} ... />
<TextBox changeTextBox={this.changeTextBox} ... />
<Toolbar data={this.state.toolbarData} />
...
)
But there don't have to be only 2 TextBox
(it depends on the user). There should be one Toolbar for every TextBox
, that is using function from actual TextBox
. As I said - TextBox
has a lot of features. So I don't think it would be good idea to turn App
and TextBox
into the same component. But I need Toolbar
to use some functions from TextBox
. Could I do this - when I click on the TextBox
changeTextBox
is called with an argument, that is an object, which contains some functions from TextBox
, and then the changeTextBox
in App
will change actual Toolbar
and this.state.toolbarData
, so Toolbar
can control the TextBox
. It is working, but it doesn't feel right. Is it a good practice or should I use something else?