babel-plugin-kea
This plugin helps auto-generate paths for kea logic.
kea({
})
kea({
path: () => ['scenes', 'homepage', 'homepageLogic']
})
kea({
key: props => props.id,
})
kea({
key: props => props.id,
path: (key) => ['scenes', 'homepage', 'homepageLogic', key]
})
kea({
path: () => ['special', 'customStuff'],
})
kea({
path: () => ['special', 'customStuff'],
})
Installation
First install the package
yarn add babel-plugin-kea --dev
npm install babel-plugin-kea --save-dev
Then add it to the list of plugins in your .babelrc
:
{
"plugins": [
"babel-plugin-kea"
]
}
Configuration
Logic paths are scoped from the current path. If you wish to skip a few parts of the path, for example
if your frontend lives under frontend/src
and you don't want every kea path to start with
frontend.src
, specify it in the config as follows:
{
"plugins": [
["babel-plugin-kea", { "path": "./frontend/src" }]
]
}