You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When building Storybooks of components that need Recoil state, it would be great to have an easy way to provide all state, including selectors. What I mean is something like this:
As mentioned in #1433 (comment) setting selectors directly raises invalidation and consistency concerns, however with a test-specific root I would not worry too much.
In fact the state here can be completely immutable, and any attempts to set an atom could go to an event instead, e.g:
<TestRecoilRootstate={[[atom1,value1]]}onSetState={({ state, value })=>{ ... }}><ComponentThatNeedsRecoil/><TestRecoilRoot>
(which allows very straightforward spying on state updates)
This discussion was converted from issue #1814 on May 26, 2022 21:20.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
When building Storybooks of components that need Recoil state, it would be great to have an easy way to provide all state, including selectors. What I mean is something like this:
As mentioned in #1433 (comment) setting selectors directly raises invalidation and consistency concerns, however with a test-specific root I would not worry too much.
In fact the state here can be completely immutable, and any attempts to set an atom could go to an event instead, e.g:
(which allows very straightforward spying on state updates)
Additionally, to cut down on boilerplate further,
TestRecoilRoot
should not share caches with any other roots, so manual approach like https://recoiljs.org/docs/guides/testing#clearing-all-selector-caches should no longer be required if using test root.Beta Was this translation helpful? Give feedback.
All reactions