JSPM

@rbxts/roact-rodux-hooked

1.1.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 124
  • Score
    100M100P100Q110890F
  • License MIT

Hooks for Rodux with roact-hooked

Package Exports

  • @rbxts/roact-rodux-hooked
  • @rbxts/roact-rodux-hooked/src/init.lua

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@rbxts/roact-rodux-hooked) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@rbxts/roact-rodux-hooked

Useful hooks for Rodux with roact-hooked

⚙️ This library only exists for use with roact-hooked

🔌 Compatible with roselect

📚 Based on @types/react-redux

Usage

import Roact from "@rbxts/roact";
import { useDispatch, useSelector } from "@rbxts/roact-rodux-hooked";
import { withHooks } from "@rbxts/roact-hooked";
import { Store, StoreState, increment } from "client/store";

function Counter() {
    const count = useSelector((state: StoreState) => state.count);
    const dispatch = useDispatch<Store>();

    return (
        <textbutton
            Text={`Counter: ${count}`}
            BackgroundColor3={Color3.fromRGB(80, 120, 200)}
            Size={new UDim2(0.5, 0, 1, 0)}
            Event={{
                Activated: () => dispatch(increment()),
            }}
        />
    );
}

export default withHooks(Counter);
import Roact from "@rbxts/roact";
import { StoreProvider } from "@rbxts/roact-rodux-hooked";
import { configureStore } from "./store";

export default function App() {
    return <StoreProvider store={configureStore()}>...</StoreProvider>;
}
import { TypedUseSelectorHook, useDispatch, useSelector, useStore } from "@rbxts/roact-rodux-hooked";
import { RootDispatch, RootState, RootStore } from "./store";

export const useRootStore = useStore as () => RootStore;
export const useRootDispatch = useDispatch as () => RootDispatch;
export const useRootSelector = useSelector as TypedUseSelectorHook<RootState>;