refactor: remove pnpm, fix tests

This commit is contained in:
littensy 2025-05-03 20:30:10 -07:00
parent 861ee5acd7
commit e34b0c9aca
65 changed files with 353 additions and 2458 deletions

View file

@ -0,0 +1,6 @@
{
"name": "ReactCharm",
"tree": {
"$path": "src"
}
}

View file

@ -0,0 +1,34 @@
local Charm = require(script.Parent.Charm)
local React = if script.Parent:FindFirstChild("react")
then require((script :: any).Parent.react) :: never
else require(script.Parent.React)
local listen = Charm.listen
local useEffect = React.useEffect
local useState = React.useState
--[=[
A hook that subscribes to changes in the given atom or selector. The
component is re-rendered whenever the state changes.
If the `dependencies` array is provided, the subscription to the atom or
selector is re-created whenever the dependencies change. Otherwise, the
subscription is created once when the component is mounted.
@param callback The atom or selector to subscribe to.
@param dependencies An array of values that the subscription depends on.
@return The current state.
]=]
local function useAtom<State>(callback: () -> State, dependencies: { any }?): State
local state, setState = useState(callback)
useEffect(function()
return listen(callback, setState)
end, dependencies or {})
return state
end
return {
useAtom = useAtom,
}

View file

@ -0,0 +1,9 @@
[package]
name = "littensy/react-charm"
version = "0.3.0"
registry = "https://github.com/UpliftGames/wally-index"
realm = "shared"
[dependencies]
Charm = "littensy/charm@^0.10"
React = "jsdotlua/react@^17"