Preact Signals: Supercharge your React/Preact development! Unleash the power of reactive programming with hooks, components, a TanStack query adapter, and more. Code smarter, not harder
MIT License
Bot releases are visible (Hide)
Published by github-actions[bot] about 2 months ago
e5c15fa: SWC plugin: added transformHooks (default: true) option
Hook is detected by RegEx that checks if function name starts with use
It transforms:
.value
(in 'auto' and 'all' modes)@useSignals
comment (in 'manual' mode)If you want to opt out from the behavior - you can set transformHooks
to false
Published by github-actions[bot] 3 months ago
Published by github-actions[bot] 3 months ago
Published by github-actions[bot] 4 months ago
dcd7e2c: Implemented experimental_stateMacrosOptimization
for automatic optimization of state macroses in JSX
Example:
import { $state, $derived } from "@preact-signals/utils/macro";
let a = $state(10);
let b = $state(20);
const c = <>{a * b + 10}</>;
Will be optimized to:
import { deepSignal as _deepSignal, $ as _$ } from "@preact-signals/utils";
let a = _deepSignal(10);
let b = _deepSignal(20);
const c = <>{_$(() => a.value * b.value + 10)}</>;
In result your components will have less rerender when using state bindings
f706a6e: Removed experimental_
prefix from stateMacro
options of @preact-signals/utils/babel
Migration (Vite):
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react({
babel: {
plugins: [
"module:@preact-signals/safe-react/babel",
[
"module:@preact-signals/utils/babel",
{
- experimental_stateMacros: true,
+ stateMacros: true,
},
],
],
},
}),
],
});
Published by github-actions[bot] 4 months ago
Published by github-actions[bot] 5 months ago
$deref
feature for state macroses to get actual state macro referencePublished by github-actions[bot] 5 months ago
Published by github-actions[bot] 5 months ago
$
Published by github-actions[bot] 5 months ago
Published by github-actions[bot] 5 months ago
Published by github-actions[bot] 5 months ago
Published by github-actions[bot] 6 months ago
reducerSignal
api (reducer pattern for signals)Published by github-actions[bot] 6 months ago
Published by github-actions[bot] 6 months ago
$derived
and $useDerived
macros
@preact-signals/utils/macro
Published by github-actions[bot] 6 months ago
Published by github-actions[bot] 6 months ago
Published by github-actions[bot] 6 months ago
Published by github-actions[bot] 6 months ago
Published by github-actions[bot] 6 months ago
983dd69: # Breaking change:
Added executeOptionsOnReferenceChange
(default: true) to reexectue mutation or query options callback on each reference change (for proper update depending on closuje)
This change is addresses issue that everything is needed to be signal to work properly with `useMutation# @preact-signals/query
const [state, setState] = useState(0);
useMutation$(() => ({
mutationFn,
onSuccess: () => {
// previous behavior - state will be recaptured only if reactive dependency changed (in case without deps it will always be 0)
// new behavior will be synced with current state value
console.log(state);
},
}));
Old behavior is can be used with executeOptionsOnReferenceChange
: false. Options callback will be reexecuted only when deps tracked by reactivity changes
const [state, setState] = useState(0);
useMutation$(() => ({
mutationFn,
executeOptionsOnReferenceChange: false,
onSuccess: () => {
// state will be recaptured only if reactive dependency changed (in case without deps it will always be 0)
console.log(state);
},
}));
useErrorBoundary
prop for `useMutation# @preact-signals/query. Now it throws an error while mutation is failedPublished by github-actions[bot] 6 months ago
Switch.Match
as alias for separete Match componentShow
stopped to be computed. Now reexcute on every parent render