Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: migrate jotai functions to useSetAtom and useAtomValue #293

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ElliotFriend
Copy link

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,

  • I've removed all imports from jotai/utils.
  • useAtomValue is now imported directly from jotai instead
  • useUpdateAtom (from jotai/utils) is replaced by useSetAtom from jotai.

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 the jotai 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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

The jotai functions currently display deprecation notices surrounding the use of several functions,
especially those from `jotai/utils`. This change migrates to the newer functions recommended by the
deprecation notices.

fix stoplightio#259
@weyert
Copy link
Contributor

weyert commented Feb 12, 2025

Awesome work, I did a similar change in my other PR #260 but a separate PR for this jotai change is much better. Never found the time to work on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Mosaic] deprecation notice from jotai
2 participants