Skip to content

Commit 744e506

Browse files
committed
fix: correct useMolecule spelling in React adapter
1 parent 2541af8 commit 744e506

7 files changed

Lines changed: 29 additions & 29 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@
5959

6060
### 🩹 Fixes
6161

62-
- Dispose molcule instances synchronously ([1f202e9](https://github.com/sigrea/react/commit/1f202e9))
63-
- Defer molcule disposal until post-rerender ([49cacc7](https://github.com/sigrea/react/commit/49cacc7))
64-
- Defer useMolcule disposal until rerender completes ([#6](https://github.com/sigrea/react/pull/6))
62+
- Dispose molecule instances synchronously ([1f202e9](https://github.com/sigrea/react/commit/1f202e9))
63+
- Defer molecule disposal until post-rerender ([49cacc7](https://github.com/sigrea/react/commit/49cacc7))
64+
- Defer useMolecule disposal until rerender completes ([#6](https://github.com/sigrea/react/pull/6))
6565

6666
### 📖 Documentation
6767

@@ -80,11 +80,11 @@
8080

8181
### ✅ Tests
8282

83-
- Cover useMolcule rerender and strict mode replay ([5aa1c34](https://github.com/sigrea/react/commit/5aa1c34))
83+
- Cover useMolecule rerender and strict mode replay ([5aa1c34](https://github.com/sigrea/react/commit/5aa1c34))
8484

8585
### 🎨 Styles
8686

87-
- Format strict-mode useMolcule test ([ec918fb](https://github.com/sigrea/react/commit/ec918fb))
87+
- Format strict-mode useMolecule test ([ec918fb](https://github.com/sigrea/react/commit/ec918fb))
8888

8989
### ❤️ Contributors
9090

@@ -95,4 +95,4 @@
9595

9696
### Minor Changes
9797

98-
- e7fa75e: Introduce the initial React adapter hooks for Sigrea molcules and signals, including playground scaffolding for manual verification.
98+
- e7fa75e: Introduce the initial React adapter hooks for Sigrea molecules and signals, including playground scaffolding for manual verification.

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
- **Signal subscriptions.** `useSignal` subscribes to signals and computed values, triggering re-renders when they change.
66
- **Computed subscriptions.** `useComputed` subscribes to computed values and memoizes them per component instance.
77
- **Deep signal subscriptions.** `useDeepSignal` subscribes to deep signal objects and exposes them for direct mutation.
8-
- **Molecule lifecycles.** `useMolcule` mounts molecule factories and binds their lifecycles to React components.
8+
- **Molecule lifecycles.** `useMolecule` mounts molecule factories and binds their lifecycles to React components.
99

1010
## Table of Contents
1111

@@ -18,7 +18,7 @@
1818
- [useSignal](#usesignal)
1919
- [useComputed](#usecomputed)
2020
- [useDeepSignal](#usedeepsignal)
21-
- [useMolcule](#usemolcule)
21+
- [useMolecule](#usemolecule)
2222
- [Testing](#testing)
2323
- [Handling Scope Cleanup Errors](#handling-scope-cleanup-errors)
2424
- [Development](#development)
@@ -52,7 +52,7 @@ export function CounterLabel() {
5252

5353
```tsx
5454
import { molecule, signal } from "@sigrea/core";
55-
import { useMolcule, useSignal } from "@sigrea/react";
55+
import { useMolecule, useSignal } from "@sigrea/react";
5656

5757
const CounterMolecule = molecule((props: { initialCount: number }) => {
5858
const count = signal(props.initialCount);
@@ -69,7 +69,7 @@ const CounterMolecule = molecule((props: { initialCount: number }) => {
6969
});
7070

7171
export function Counter(props: { initialCount: number }) {
72-
const counter = useMolcule(CounterMolecule, props);
72+
const counter = useMolecule(CounterMolecule, props);
7373
const value = useSignal(counter.count);
7474

7575
return (
@@ -133,10 +133,10 @@ function useDeepSignal<T extends object>(signal: DeepSignal<T>): T
133133

134134
Exposes a deep signal object for direct mutation within the component. Updates to nested properties trigger re-renders, and the subscription is cleaned up when the component unmounts.
135135

136-
### useMolcule
136+
### useMolecule
137137

138138
```tsx
139-
function useMolcule<TProps, TReturn>(
139+
function useMolecule<TProps, TReturn>(
140140
molecule: MoleculeFactory<TProps, TReturn>,
141141
props?: TProps
142142
): TReturn

packages/__tests__/useMolcule.strict-mode.test.ts renamed to packages/__tests__/useMolecule.strict-mode.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
33

44
import { disposeTrackedMolecules, molecule, onUnmount } from "@sigrea/core";
55

6-
import { useMolcule } from "../useMolcule";
6+
import { useMolecule } from "../useMolecule";
77
import { createTestRoot, flushMicrotasks } from "./testUtils";
88

9-
describe("useMolcule in StrictMode", () => {
9+
describe("useMolecule in StrictMode", () => {
1010
let root: ReturnType<typeof createTestRoot>;
1111

1212
beforeEach(() => {
@@ -20,13 +20,13 @@ describe("useMolcule in StrictMode", () => {
2020

2121
it("keeps the molecule instance alive across StrictMode effect replays", async () => {
2222
const cleanup = vi.fn();
23-
const counterMolcule = molecule((value: number) => {
23+
const counterMolecule = molecule((value: number) => {
2424
onUnmount(() => cleanup(value));
2525
return { value };
2626
});
2727

2828
function TestComponent() {
29-
useMolcule(counterMolcule, 1);
29+
useMolecule(counterMolecule, 1);
3030
return null;
3131
}
3232

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import {
88
onUnmount,
99
} from "@sigrea/core";
1010

11-
import { useMolcule } from "../useMolcule";
11+
import { useMolecule } from "../useMolecule";
1212
import { createTestRoot, flushMicrotasks } from "./testUtils";
1313

14-
describe("useMolcule", () => {
14+
describe("useMolecule", () => {
1515
let root: ReturnType<typeof createTestRoot>;
1616

1717
beforeEach(() => {
@@ -25,15 +25,15 @@ describe("useMolcule", () => {
2525

2626
it("does not dispose when re-rendered with identical props", async () => {
2727
const cleanup = vi.fn();
28-
const counterMolcule = molecule((value: number) => {
28+
const counterMolecule = molecule((value: number) => {
2929
onUnmount(() => cleanup(value));
3030
return { value };
3131
});
3232

3333
const observed: Array<MoleculeInstance<{ value: number }>> = [];
3434

3535
function TestComponent({ value }: { value: number }) {
36-
const instance = useMolcule(counterMolcule, value);
36+
const instance = useMolecule(counterMolecule, value);
3737
observed.push(instance);
3838
return null;
3939
}
@@ -56,15 +56,15 @@ describe("useMolcule", () => {
5656

5757
it("mounts molecule and cleans up on unmount", async () => {
5858
const cleanup = vi.fn();
59-
const makeMolcule = molecule((value: number) => {
59+
const makeMolecule = molecule((value: number) => {
6060
onUnmount(() => cleanup(value));
6161
return { value };
6262
});
6363

6464
const observed: Array<MoleculeInstance<{ value: number }>> = [];
6565

6666
function TestComponent() {
67-
const instance = useMolcule(makeMolcule, 1);
67+
const instance = useMolecule(makeMolecule, 1);
6868
observed.push(instance);
6969
return null;
7070
}
@@ -86,14 +86,14 @@ describe("useMolcule", () => {
8686
const mounts = vi.fn();
8787
const cleanups = vi.fn();
8888

89-
const counterMolcule = molecule((value: number) => {
89+
const counterMolecule = molecule((value: number) => {
9090
mounts(value);
9191
onUnmount(() => cleanups(value));
9292
return {};
9393
});
9494

9595
function TestComponent({ value }: { value: number }) {
96-
useMolcule(counterMolcule, value);
96+
useMolecule(counterMolecule, value);
9797
return null;
9898
}
9999

packages/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* ==================================================
55
*/
66

7-
export { useMolcule } from "./useMolcule";
7+
export { useMolecule } from "./useMolecule";
88

99
/**
1010
* ==================================================
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ interface MoleculeState<TReturn extends object, TProps> {
1616
pendingDisposeToken: symbol | null;
1717
}
1818

19-
export function useMolcule<TReturn extends object, TProps = void>(
19+
export function useMolecule<TReturn extends object, TProps = void>(
2020
molecule: MoleculeFactory<TReturn, TProps>,
2121
...args: MoleculeArgs<TProps>
2222
): MoleculeInstance<TReturn> {
@@ -56,7 +56,7 @@ export function useMolcule<TReturn extends object, TProps = void>(
5656
const state = stateRef.current;
5757
if (state === undefined) {
5858
throw new Error(
59-
"useMolcule failed to mount the requested molecule instance.",
59+
"useMolecule failed to mount the requested molecule instance.",
6060
);
6161
}
6262

playground/src/Counter.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useMemo } from "react";
22

3-
import { useMolcule, useSignal } from "@sigrea/react";
3+
import { useMolecule, useSignal } from "@sigrea/react";
44
import { CounterMolecule, type CounterProps } from "./CounterMolecule";
55

66
export function Counter(props: CounterProps) {
@@ -10,7 +10,7 @@ export function Counter(props: CounterProps) {
1010
[initialCount, step],
1111
);
1212

13-
const counter = useMolcule(CounterMolecule, moleculeProps);
13+
const counter = useMolecule(CounterMolecule, moleculeProps);
1414
const count = useSignal(counter.count);
1515

1616
return (

0 commit comments

Comments
 (0)