@unhead/react 2.0.11 → 2.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +11 -6
  2. package/package.json +5 -5
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useContext, useState, useMemo, useCallback, useRef } from 'react';
1
+ import React, { useEffect, useContext, useRef, useMemo, useCallback } from 'react';
2
2
  import { ValidHeadTags, TagsWithInnerContent, HasElementTags } from 'unhead/utils';
3
3
  import { useScript as useScript$1, useHead as useHead$1, useHeadSafe as useHeadSafe$1, useSeoMeta as useSeoMeta$1 } from 'unhead';
4
4
  import { U as UnheadContext } from './shared/react.DF9T1fqs.mjs';
@@ -21,15 +21,20 @@ function useUnhead() {
21
21
  }
22
22
  function withSideEffects(input, options, fn) {
23
23
  const unhead = options.head || useUnhead();
24
- const [entry] = useState(() => fn(unhead, input, options));
24
+ const entryRef = useRef(null);
25
+ if (!entryRef.current) {
26
+ entryRef.current = fn(unhead, input, options);
27
+ }
28
+ const entry = entryRef.current;
25
29
  useEffect(() => {
26
- entry.patch(input);
27
- }, [input]);
30
+ entry?.patch(input);
31
+ }, [input, entry]);
28
32
  useEffect(() => {
29
33
  return () => {
30
- entry.dispose();
34
+ entry?.dispose();
35
+ entryRef.current = null;
31
36
  };
32
- }, []);
37
+ }, [entry]);
33
38
  return entry;
34
39
  }
35
40
  function useHead(input = {}, options = {}) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unhead/react",
3
3
  "type": "module",
4
- "version": "2.0.11",
4
+ "version": "2.0.13",
5
5
  "author": "Harlan Wilton <harlan@harlanzw.com>",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",
@@ -61,7 +61,7 @@
61
61
  "dist"
62
62
  ],
63
63
  "peerDependencies": {
64
- "react": ">=18"
64
+ "react": ">=18.3.1"
65
65
  },
66
66
  "build": {
67
67
  "external": [
@@ -69,12 +69,12 @@
69
69
  ]
70
70
  },
71
71
  "dependencies": {
72
- "unhead": "2.0.11"
72
+ "unhead": "2.0.13"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@testing-library/react": "^16.3.0",
76
- "react": "^19.1.0",
77
- "react-dom": "^19.1.0"
76
+ "react": "^19.1.1",
77
+ "react-dom": "^19.1.1"
78
78
  },
79
79
  "scripts": {
80
80
  "build": "unbuild",