Skip to content

Get instance of Store with generics from InstanceKeeper in right way #96

Answered by arkivanov
t1r asked this question in Q&A
Discussion options

You must be logged in to vote

I checked the sample, it doesn't work because you are creating both components with the same ComponentContext here. As I mentioned earlier, sharing component contexts between multiple components is error prone and discouraged.

There are two options:

  1. Wrap those two components into another container component, and use childContext for every child component.
  2. Just write addFoodEntry(componentContext.childContext("food")), and similarity for the second component.

In this case you won't need specifying keys in child components.

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@t1r
Comment options

Answer selected by t1r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants