React x xignal
npm install @xignal/react
React x xignal
npm i xignal @xignal/react
``ts
// ./signal.ts
import * as xignal from "xignal";
export const count = xignal.state(0);
export const doubled = xignal.computed(() => count.get() * 2);
`
#### useSignalValue
`tsx
// ./counter.tsx
import { useSignalValue } from "@xignal/react";
import { count, doubled } from "./signal";
const Counter = () => {
const countValue = useSignalValue(count);
const doubledValue = useSignalValue(doubled);
return (
`
#### useSignalState
`tsx
import { useSignalState } from "@xignal/react";
import { count } from "./signal";
const Component = () => {
const [countValue, countUpdate] = useSignalState(count);
};
`
#### useSignalComputed
`tsx
import { useSignalComputed } from "@xignal/react";
import { count } from "./signal";
const Component = () => {
const doubledValue = useSignalComputed(() => count.get() * 2);
};
`
`tsx
import * as xignal from "xignal";
import { Show } from "@xignal/react";
const shouldShow = xignal.state(false);
const App = () => {
return
};
`
#### Utils
`ts
import { createStateWithUseSignalValue, createComputedWithUseSignalValue } from "@xignal/react";
const [count, useCount] = createStateWithUseSignalValue(0);
const [doubled, useDoubled] = createComputedWithUseSignalValue(() => count.get() * 2);
``
MIT