Changelog
effector-react 22.3.0
useEvent
, useStore
, useStoreMap
and useList
isomorphic, now they would use scope
from the Provider
if it is available and scope-less mode otherwise. For useUnit
it was done in 22.2.0.forceScope
to useEvent
, useStore
, useStoreMap
and useList
to force usage of scope from Provider
, it would throw an error if Provider
is not available, /scope
module sets forceScope
to true
by defaultChangelog
effector-vue 22.2.0
useStoreMap
hook for Vue 3 composition API to select part from a store ((PR #780)[https://github.com/effector/effector/pull/780]) by @ilajosmanovChangelog
effector 22.1.1
.on
and .reset
methodsChangelog
effector-react 22.1.0
useUnit
method to read multiple stores and bind events or effects to scope in a single batched call (PR #733, #738)import {value createEvent, value createStore, value fork} from 'effector'
import {value useUnit, value Provider} from 'effector-react/scope'
const inc = createEvent()
const $count = createStore(0)
const $title = createStore('useStore example')
$count.on(inc, x => x + 1)
const App = () => {
const [count, title, incFn] = useUnit([$count, $title, inc])
return (
<>
<h1>{title}</h1>
<p>Count: {count}</p>
<button onClick={() => incFn()}>increment</button>
</>
)
}
const scope = fork()
render(
() => (
<Provider value={scope}>
<App />
</Provider>
),
document.getElementById('root'),
)
placeholder
option to useList
to render in cases of empty listconst ChatList = () => (
<div>
{useList($chats, {
fn: chat => <div>Chat {chat.name}</div>,
keys: [],
placeholder: <div>You have no chats yet. Add first one?</div>,
})}
</div>
)
defaultValue
option to useStoreMap
to return in cases when fn
returns undefinedconst ChatName = ({id}) => {
const chat = useStoreMap({
store: $chats,
keys: [id],
fn: chats => chats.find(chat => chat.id === id),
defaultValue: {id: 'default', name: 'Default chat'},
})
return <span>{chat.name}</span>
}
Gate.status
store being serialized (PR #683)