Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@rbxts/react-reflex
Advanced tools
Reflex is a simple state container inspired by Rodux and Silo, designed to be an all-in-one solution for managing and reacting to state in Roblox games.
This package provides Reflex bindings for React using @rbxts/react-ts
.
See the full documentation for Reflex here.
$ npm install @rbxts/react-reflex
$ pnpm add @rbxts/react-reflex
Reflex offers support for @rbxts/react-ts
with @rbxts/react-reflex
. Using react-reflex hooks requires setting up a ReflexProvider
at the root of your Roact tree.
If you don't want to use generics to get the Producer type you want, Reflex exports the UseSelectorHook
and UseProducerHook
types to make it easier:
export const useRootProducer: UseProducerHook<RootProducer> = useProducer;
export const useRootSelector: UseSelectorHook<RootProducer> = useSelector;
export function App() {
const { increment, decrement } = useRootProducer();
const count = useRootSelector((state) => state.count);
return (
<textbutton
Text={`Count: ${count}`}
AnchorPoint={new Vector2(0.5, 0.5)}
Size={new UDim2(0, 100, 0, 50)}
Position={new UDim2(0.5, 0, 0.5, 0)}
Event={{
Activated: () => increment(),
MouseButton2Click: () => decrement(),
}}
/>
);
}
Roact.mount(
<ReflexProvider producer={producer}>
<App />
</ReflexProvider>,
);
When using selector creators, you should avoid creating them in your render method (i.e. useSelector(selectPlayersOnTeam(redTeam))
), since it creates a new selector every time the component renders and risks excessive re-renders. Instead, you can use the useSelectorCreator()
hook to memoize the selector:
export const selectPlayersOnTeam = (team: Team) => {
return createSelector([selectPlayers] as const, (players) => {
return players.filter((player) => player.Team === team);
});
};
const players = useSelectorCreator(selectPlayersOnTeam, redTeam);
Reflex is licensed under the MIT License.
FAQs
React bindings for Reflex
The npm package @rbxts/react-reflex receives a total of 80 weekly downloads. As such, @rbxts/react-reflex popularity was classified as not popular.
We found that @rbxts/react-reflex demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.