fix: migrate jotai functions to useSetAtom and useAtomValue #293
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, there!! Hope this isn't an unwelcome contribution.
The jotai functions currently display deprecation notices surrounding the use of several functions, especially those from
jotai/utils
.fix #259
Motivation and Context
We use the
@MetaMask/open-rpc-docs-react
package for our Docusaurus site. Every time we build, there are many deprecation notices, just like is mentioned in issue #259. I've experimented with locally applying a patch to the package once downloaded, and the deprecation warnings disappear. This PR is a more "proper" form of that fix.Description
This change migrates to the newer functions recommended by the deprecation notices. To accomplish this,
jotai/utils
.useAtomValue
is now imported directly fromjotai
insteaduseUpdateAtom
(fromjotai/utils
) is replaced byuseSetAtom
fromjotai
.How Has This Been Tested?
I've made the same changes to the
node_modules
version of this package in my local Docusaurus site, and the build proceeds with no deprecation notices.I've also run the
yarn test.prod
script, and all tests pass. The functions I've used to replace the deprecated ones seem like drop-in replacements, and there shouldn't be any trouble. In this (old) commit in thejotai
package, they're using these same functions "internally" for these deprecated functions I'm replacing.I'm not sure if it's necessary to add error reporting or more test cases for a change this "simple," but I'm more than happy to add them if it's required.
Types of changes
Checklist