preact-signals

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

Downloads
9.5K
Stars
65
Committers
4

Bot releases are visible (Hide)

preact-signals - @preact-signals/[email protected] Latest Release

Published by github-actions[bot] about 2 months ago

Minor Changes

  • e5c15fa: SWC plugin: added transformHooks (default: true) option

    Hook is detected by RegEx that checks if function name starts with use

    It transforms:

    • every hook that reads .value (in 'auto' and 'all' modes)
    • every hook that has @useSignals comment (in 'manual' mode)

    If you want to opt out from the behavior - you can set transformHooks to false

preact-signals - @preact-signals/[email protected]

Published by github-actions[bot] 3 months ago

Patch Changes

  • 661a86e: babel plugin: removed unexpected logging
preact-signals - @preact-signals/[email protected]

Published by github-actions[bot] 3 months ago

Patch Changes

preact-signals - @preact-signals/[email protected]

Published by github-actions[bot] 4 months ago

Minor Changes

  • 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,
                },
              ],
            ],
          },
        }),
      ],
    });
    
preact-signals - @preact-signals/[email protected]

Published by github-actions[bot] 4 months ago

Patch Changes

  • Updated dependencies [dcd7e2c]
  • Updated dependencies [f706a6e]
preact-signals - @preact-signals/[email protected]

Published by github-actions[bot] 5 months ago

Minor Changes

  • b29dbc5: Disallow reexports from macro lib
  • b29dbc5: Added $deref feature for state macroses to get actual state macro reference
preact-signals - @preact-signals/[email protected]

Published by github-actions[bot] 5 months ago

Patch Changes

  • Updated dependencies [b29dbc5]
  • Updated dependencies [b29dbc5]
preact-signals - @preact-signals/[email protected]

Published by github-actions[bot] 5 months ago

Patch Changes

  • 1b339b4: Fixed incorrect babel transform of state macro identifier inside of $
preact-signals - @preact-signals/[email protected]

Published by github-actions[bot] 5 months ago

Patch Changes

preact-signals - @preact-signals/[email protected]

Published by github-actions[bot] 5 months ago

Patch Changes

  • 79d2ace: Updated @babel/helper-module-imports
  • 3801b85: [babel]: started to refernce variables
preact-signals - @preact-signals/[email protected]

Published by github-actions[bot] 5 months ago

Patch Changes

  • Updated dependencies [79d2ace]
  • Updated dependencies [3801b85]
preact-signals - @preact-signals/[email protected]

Published by github-actions[bot] 6 months ago

Minor Changes

  • b9d6034: Implemented reducerSignal api (reducer pattern for signals)

Patch Changes

  • b9d6034: Improved hooks documentation
preact-signals - @preact-signals/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

  • Updated dependencies [b9d6034]
  • Updated dependencies [b9d6034]
preact-signals - @preact-signals/[email protected]

Published by github-actions[bot] 6 months ago

Minor Changes

  • 84b296d: - implemented $derived and $useDerived macros
    • documented state macros
  • 253049c: Added validation of esm imports from @preact-signals/utils/macro

Patch Changes

  • 84b296d: Updated repository links
  • Updated dependencies [84b296d]
preact-signals - @preact-signals/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

  • 84b296d: Updated repository links
preact-signals - @preact-signals/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

  • 84b296d: Updated repository links
preact-signals - @preact-signals/[email protected]

Published by github-actions[bot] 6 months ago

Patch Changes

  • 6b09439: Export `useQueryClient# @preact-signals/query
  • 84b296d: Updated repository links
  • Updated dependencies [84b296d]
  • Updated dependencies [253049c]
  • Updated dependencies [84b296d]
preact-signals - @preact-signals/[email protected]

Published by github-actions[bot] 6 months ago

Minor Changes

preact-signals - @preact-signals/[email protected]

Published by github-actions[bot] 6 months ago

Major Changes

  • 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);
      },
    }));
    

Patch Changes

  • e1ab313: Fixed work of useErrorBoundary prop for `useMutation# @preact-signals/query. Now it throws an error while mutation is failed
  • e1ab313: Fixed incorrect `useMutation# @preact-signals/query return type
  • e1ab313: Mutations options used to be never updated after mutation creation
preact-signals - @preact-signals/[email protected]

Published by github-actions[bot] 6 months ago

Minor Changes

  • 02878e1: Removed caching from Switch component. Added Switch.Match as alias for separete Match component
  • f40d84f: Show stopped to be computed. Now reexcute on every parent render

Patch Changes

  • b7f18de: Removed unecessary signal creation in Computed