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

Roadmap to v1 #333

Closed
49 tasks done
dai-shi opened this issue Mar 4, 2021 · 6 comments
Closed
49 tasks done

Roadmap to v1 #333

dai-shi opened this issue Mar 4, 2021 · 6 comments

Comments

@dai-shi
Copy link
Member

dai-shi commented Mar 4, 2021

We are getting ready. Here's action items.

Fixing bugs

For this we need more bug reports.

Improving docs

This is most important for v1.

Improving types and tests

Improving apis

Benchmarking

Devtools

We have useDebugState in Provider and jotai/devtools for Redux DevTools Ext.

It would be nice to have a dedicated devtools.

Adding features

This is actually not required for v1, but nice to have.

Tutorials

Maybe we should do this outside repo.
Anyone would like to write blog posts or something?

Release Note

  • Prepare release note draft
Draft

Announcing Jotai v1

preview

We are pleased to announce jotai v1 release!
Jotai is a primitive and flexible state management library for React.

Demos:

Global state like useState

Jotai's atoms can be used like useState, but it's global state.

const yearAtom = atom(2021)

const Component = () => {
  const [year, setYear] = useAtom(yearAtom)
  return <>{year} <button onClick={() => setYear((c) => c + 1)}>Next</button>
}

Derived state

You can create a derived atom with read function.

const meterAtom = atom(1000)
const kilometerAtom = atom((get) => get(meterAtom) / 1000)

Minimal API and additional utilities

Jotai core jotai exposes only two functions atom, useAtom and one optional component Provider.

We have more functions in separate bundles jotai/*, such as jotai/utils and jotai/devtools.
For example, those include atomWithStorage, atomWithReset, atomFamily, to name a few.
They are all implemented with the public api of jotai core.
So, you can also create a similar third-party library.

Async support

Jotai comes with Suspense support. If your read function is async, it will suspend behind the scenes, and you wouldn't need to care async state in your code.

const idAtom = atom('id001')
const dataAtom = atom(async (get) => {
  const response = await fetch(`.../${id}`)
  return response.json()
}

const Component = () => {
  const [data] = useAtom(dataAtom)
  return <>{data.title} - {data.author}</>
}

Notes about Suspense

We use the undocumented behavior of "Suspense for Lazy Loading" for any async.
"Suspense for Data Fetching" is still to be finalized.
Hence, this feature is technically unstable. We try our best to keep the API when it migrates.

Integrations

Jotai comes with various integrations. Some of them are complete, some are preliminary.

Moving forward

The core API should be stable for React 16.8 and above.
All major issues are resolved, and if there is a bug by chance, we will fix it as soon as possible.

We will be adding more utility functions on top of core, and your use cases would be important. Free free to open a new discussion.

We are already working on new integrations for urql and rxjs. We have a plan to work on dedicated integration for nextjs.

When React releases a new version with Suspense and Concurrent support, we will start working on the next major version. Our hope is to keep the API compatible.

Notes about Versioning

We follow semantic versioning for core jotai.
Note that type-only changes and sub bundles jotai/* don't strictly follow the semver.
Please check release notes for details.

@Thisen
Copy link
Collaborator

Thisen commented Mar 4, 2021

I think basic devtools should be a part of v1. Then we will know that the snapshot parts are stable.

@Aslemammad
Copy link
Member

@Aslemammad, I think I'm gonna do some about blog posts. But I have to finish some stuff going on here.

@dai-shi dai-shi pinned this issue Mar 6, 2021
This was referenced Mar 30, 2021
@RIP21
Copy link
Contributor

RIP21 commented Apr 16, 2021

If some will wrap urql client into jotai it will be awesome :) But I guess it will require some good knowledge of internals to make it right.
This thingy :)
https://github.com/FormidableLabs/urql

@dai-shi
Copy link
Member Author

dai-shi commented Apr 16, 2021

@RIP21 Nice idea. Would you create a dedicated issue please? I'm interested, but if someone is too, they can try.

@RIP21
Copy link
Contributor

RIP21 commented Apr 16, 2021

@dai-shi done #427 :)
BTW, thanks for your work! :) Love Jotai so far :)

@dai-shi dai-shi unpinned this issue Jun 16, 2021
@dai-shi
Copy link
Member Author

dai-shi commented Jun 16, 2021

We did it! 🎉 🎉 🎉

@dai-shi dai-shi closed this as completed Jun 16, 2021
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

No branches or pull requests

4 participants