Skip to content

Releases: preactjs/signals

@preact/signals-debug@1.4.2

Choose a tag to compare

@github-actions github-actions released this 22 Feb 06:02
b35aa34

Patch Changes

@preact/signals@2.8.1

Choose a tag to compare

@github-actions github-actions released this 16 Feb 17:27
fec042b

Patch Changes

@preact/signals-devtools-ui@0.4.1

Choose a tag to compare

@github-actions github-actions released this 15 Feb 10:06
e330c33

Patch Changes

@preact/signals-debug@1.4.1

Choose a tag to compare

@github-actions github-actions released this 15 Feb 10:06
e330c33

Patch Changes

@preact/signals@2.8.0

Choose a tag to compare

@github-actions github-actions released this 13 Feb 18:29
e20d0ff

Minor Changes

@preact/signals-react@3.9.0

Choose a tag to compare

@github-actions github-actions released this 13 Feb 18:29
e20d0ff

Minor Changes

@preact/signals@2.7.1

Choose a tag to compare

@github-actions github-actions released this 09 Feb 07:20
93d71f6

Patch Changes

@preact/signals@1.3.4

Choose a tag to compare

@github-actions github-actions released this 07 Feb 10:20
ff524dc

Patch Changes

@preact/signals@2.7.0

Choose a tag to compare

@github-actions github-actions released this 04 Feb 08:11
28b5900

Minor Changes

  • #861 5794b04 Thanks @andrewiggins! - Add useModel hook for using Models in components

    The new useModel hook provides a convenient way to use Models (created with createModel) within React and Preact components. It handles:

    • Creating the model instance lazily on first render
    • Maintaining the same instance across re-renders
    • Automatically disposing the model when the component unmounts
    import { createModel, signal } from "@preact/signals-core";
    import { useModel } from "@preact/signals-react"; // or "@preact/signals"
    
    const CountModel = createModel(() => ({
    	count: signal(0),
    	increment() {
    		this.count.value++;
    	},
    }));
    
    function Counter() {
    	const model = useModel(CountModel);
    	return <button onClick={() => model.increment()}>{model.count}</button>;
    }

    For models that require constructor arguments, wrap in a factory function:

    const CountModel = createModel((initialCount: number) => ({
      count: signal(initialCount),
    }));
    
    function Counter() {
      const model = useModel(() => new CountModel(5));
      return <div>{model.count}</div>;
    }

Patch Changes

  • #865 4872968 Thanks @JoviDeCroock! - Revert #728 - this might entail work in prefresh but currently the presence of uesState makes every sCU bail

  • Updated dependencies [19ac39b]:

    • @preact/signals-core@1.13.0

@preact/signals-react@3.8.0

Choose a tag to compare

@github-actions github-actions released this 04 Feb 08:11
28b5900

Minor Changes

  • #861 5794b04 Thanks @andrewiggins! - Add useModel hook for using Models in components

    The new useModel hook provides a convenient way to use Models (created with createModel) within React and Preact components. It handles:

    • Creating the model instance lazily on first render
    • Maintaining the same instance across re-renders
    • Automatically disposing the model when the component unmounts
    import { createModel, signal } from "@preact/signals-core";
    import { useModel } from "@preact/signals-react"; // or "@preact/signals"
    
    const CountModel = createModel(() => ({
    	count: signal(0),
    	increment() {
    		this.count.value++;
    	},
    }));
    
    function Counter() {
    	const model = useModel(CountModel);
    	return <button onClick={() => model.increment()}>{model.count}</button>;
    }

    For models that require constructor arguments, wrap in a factory function:

    const CountModel = createModel((initialCount: number) => ({
      count: signal(initialCount),
    }));
    
    function Counter() {
      const model = useModel(() => new CountModel(5));
      return <div>{model.count}</div>;
    }

Patch Changes

  • Updated dependencies [19ac39b]:
    • @preact/signals-core@1.13.0