useid-polyfill 1.0.3 → 1.0.4
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.
- package/README.md +6 -1
- package/dist/index.d.mts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,10 +29,15 @@ function FormField({ label }: { label: string }) {
|
|
|
29
29
|
|
|
30
30
|
## API
|
|
31
31
|
|
|
32
|
-
### `useId()
|
|
32
|
+
### `useId()`
|
|
33
33
|
|
|
34
34
|
Returns a unique, stable ID string. On React 18+, delegates to the native `React.useId()`.
|
|
35
35
|
|
|
36
|
+
TypeScript return type is conditional on your installed React typings:
|
|
37
|
+
|
|
38
|
+
- React 18+ typings: `string`
|
|
39
|
+
- React 16/17 typings: `string | undefined`
|
|
40
|
+
|
|
36
41
|
On React 16/17 during SSR, returns `undefined` on the initial server render and hydration pass, then resolves to a string ID after a layout effect. This avoids hydration mismatches.
|
|
37
42
|
|
|
38
43
|
## SSR Caveats
|
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var a=Object.create;var
|
|
1
|
+
"use strict";var a=Object.create;var o=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var l=(e,t)=>{for(var n in t)o(e,n,{get:t[n],enumerable:!0})},i=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let d of I(t))!m.call(e,d)&&d!==n&&o(e,d,{get:()=>t[d],enumerable:!(r=p(t,d))||r.enumerable});return e};var y=(e,t,n)=>(n=e!=null?a(g(e)):{},i(t||!e||!e.__esModule?o(n,"default",{value:e,enumerable:!0}):n,e)),R=e=>i(o({},"__esModule",{value:!0}),e);var L={};l(L,{useId:()=>c});module.exports=R(L);var x=y(require("react")),s=require("react"),E={...x},U=0,h=Math.random().toString(36).slice(2,6),u=()=>`uid-${h}${U++}`,v=typeof window!="undefined"?s.useLayoutEffect:s.useEffect,f=!1;function w(){let[e,t]=(0,s.useState)(()=>f?u():void 0);return v(()=>{e===void 0&&t(u())},[]),(0,s.useEffect)(()=>{f||(f=!0)},[]),e}var c=E.useId||w;0&&(module.exports={useId});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as o from"react";import{useState as f,useEffect as s,useLayoutEffect as r}from"react";var i={...o},u=0,c=Math.random().toString(36).slice(2,6),n=()=>`uid-${c}${u++}`,a=typeof window!="undefined"?r:s,e=!1;function p(){let[t,d]=f(()=>e?n():void 0);return a(()=>{t===void 0&&d(n())},[]),s(()=>{e||(e=!0)},[]),t}var I=i.useId||p;export{I as useId};
|