mirror of
https://github.com/littensy/charm.git
synced 2026-10-21 11:44:08 +00:00
fix: call selector with atom state
This commit is contained in:
parent
0046af5598
commit
8a0d0977ca
2 changed files with 4 additions and 2 deletions
|
|
@ -13,7 +13,7 @@ local function useAtomState<State>(atom: Atom<State>, selector: ((State) -> Stat
|
|||
local React = requireReact()
|
||||
|
||||
local state, setState = React.useState(function()
|
||||
return if selector then atom(selector) else atom()
|
||||
return if selector then selector(atom()) else atom()
|
||||
end)
|
||||
|
||||
local latestSelector = React.useRef(selector)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue