Skip to main content

Roact Reflex

Reflex offers bindings for Roact and Roact Hooked that allow you to use Hooks to read and dispatch actions to a Reflex producer from a component.


Quick Start

The official bindings for Reflex and Roact Hooked are available under @rbxts/roact-reflex. Currently, there is no support for Luau projects.

See the source code on GitHub →

Terminal
npm install @rbxts/roact-reflex

Components

Roact Reflex allows you to use your root producer from Roact function components. It exposes a component that you can use to specify the producer for Hooks to use:

Roact.mount(
<ReflexProvider producer={producer}>
<App />
</ReflexProvider>,
playerGui,
);

Hooks

You can use Hooks to read and subscribe to state, or to dispatch actions. Use these Hooks in function components that are wrapped in a <ReflexProvider>.

Context Hooks

Use these Hooks to access the root producer and dispatch actions:

function Button() {
const { increment } = useProducer();
// ...

State Hooks

Use these Hooks to read and subscribe to state:

function Counter() {
const count = useSelector((state) => state.count);
// ...

Guides