To create a new app based on kea's create-react-app typescript template, run the following:
This sets up a new project with
kea-typegen, and adds
kea-loaders. It's the fastest way to just try out Kea.
kea is rather straightforward. You need to install some packages, optionally call
and wrap your app with a
<Provider /> tag.
Kea stores all of its data on a context, which must be set up before any
logic can be used. This
context stores a reference to the redux store, initializes all plugins, caches all built logic and keeps
track of what is mounted and what is not.
To set it up, just call
resetContext(options) before rendering your app.
3. Wrap with
Then wrap your
<App /> with
This is how your
index.js would look like if you used
That's it! Feel free to use
kea() calls anywhere in your code!
If you're using TypeScript (and everybody should), you'll need to set up kea-typegen as well.
First, run the following:
Then add the following to your
Finally, change your start script in
Read more about TypeScript Support in Kea.
- Read Core Concepts to get a good understanding of how Kea works and why.