Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi Alfonso!
I have been doing some updates to my (now 4 year-old!) Fable client project, including recently updating to Fable 4.
What an enjoyable project it has been! Thank you again for all you have done with Fable.
Anyways, I wanted to refactor my usage of
React.useContext
to use a full-fledged shared/global Elmish loop, similar to what I can do with Fable.LitStore, but using Fable.ReactStore. (See this discussion on Twitter for more context.)The closest function I could find in the Fable.ReactStore package was
useStoreLazy
, but it was problematic in that it would not always refresh changes to the store from one component into another. I finally came to the conclusion that maybeuseStoreLazy
was meant for a more specific use case than what I needed.So, I ended up porting my original port of
useStore
that became Fable.LitStore into Fable.ReactStore. This does exactly what I need and allows me to phase outReact.useContext
in my application.(One other thing: I wasn't sure if there is a better way to share a global Elmish loop via the new Fable.React
React.useElmish
in Fable 4, but I didn't see a way to do it.)Example
Global/Shared Elmish Loop
Sharing context in components