This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
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.
Summary
I made the following changes in a fork of hookstate that this branch is pulling in. This should be carefully reviewed.
Previously, this either crashed, or (if the behavior was needed) required a very awkward work-around w/ sub-reactors. IMO, just this one change is a HUGE improvement.
Other very minor (one-line) changes:
React throws errors when setting values before a component is done mounting - This was due to hookstate calling
setValue
in reactors that haven't finished mounting yet, due to state changes in hooked global states.setValue
after the component has mounted. This error should no longer be caused by hookstate. This change is defininitely worth keeping IMO.HOOKSTATE-106: This error is caused by attempting to update a state after it has already been destroyed (e.g., due to unmounting). I've seen this error a few times in our engine. In React, this scenario is essentially ignored (React doesn't seem to care at all of if setValue is called after it's context has unmounted and state destroyed).
Subtasks Checklist
Still a draft, needs some cleanup.
Breaking Changes
The latest version of hookstate types
state.value
andstate.get()
as read-only (this is nice for type-safety)getState()
andgetComponent()
return values.This old pattern:
useHookstate(getMutableState(X))
now produces broken typings that I can't fix.useMutableState(X)
(this one has working types)The hookstate plugin API changed, and is now an
extension
api.syncStateWithLocalStorage
plugin has been rewritten to the new extension formatextension
property for adding hookstate extensionsReferences
closes #insert number here
QA Steps