I just encountered a strange behaviour with my reasonreact + reasonapollo application.
<MainComponent>
/* getSomeData Query returns
{ foo: "test, bar: "test2", items: [1,2,3,4,5,6] } */
<FirstQueryComponent />
<Content>
/* getSampleData Query returns { items: [1,2,3,4] } */
<SecondQueryComponent />
</Content>
</MainComponent>
Both components render the same data items
, they just use different queries to get some filtered data.
Lets say, <SecondQueryComponent />
is rendered on some condition.
Now the App renders and everything is fine, that means:
-
<FirstQueryComponent />
renders with all 6 items
Now the <MainComponent />
updates its state ( user clicked a button for example), and the condition changes to true.
Since <FirstQueryComponent />
is a Child, it rerenders.
BUT it rerenders with the filtered data from <SecondQueryComponent />
so the data now looks like this:
{ foo: "test, bar: "test2", items: [1,2,3,4] }
(items has now the same array as the data from SecondQueryComponent
).
They both use different CreateQuery Modules. There is also no new graphql request, FirstQueryComponent
just gets a new result and suddenly the nested items
are the same as from SeconQueryComponent
.
Are the key: value pairs somehow connected because of the same “key”?
I dont know how to explain it better Its really strange and i have no clue how this happens. Maybe someone here encountered the same and knows where my error is. I clearly did something wrong, but i dont know what it is.