@tamagui/use-did-finish-ssr
Advanced tools
Comparing version 1.115.5 to 1.116.0
@@ -27,19 +27,10 @@ "use strict"; | ||
useClientValue: () => useClientValue, | ||
useDidFinishSSR: () => useDidFinishSSR, | ||
useDidFinishSSRSync: () => useDidFinishSSRSync | ||
useDidFinishSSR: () => useDidFinishSSR | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
var React = __toESM(require("react")), emptyFn = function() { | ||
}, emptyFnFn = function() { | ||
return emptyFn; | ||
}; | ||
function useDidFinishSSR(value, options) { | ||
var React = __toESM(require("react")); | ||
function useDidFinishSSR(value) { | ||
return value ?? !0; | ||
var cur, setCur; | ||
} | ||
function useDidFinishSSRSync(value) { | ||
return useDidFinishSSR(value, { | ||
sync: !0 | ||
}); | ||
} | ||
function useClientValue(value) { | ||
@@ -52,5 +43,4 @@ var done = useDidFinishSSR(); | ||
useClientValue, | ||
useDidFinishSSR, | ||
useDidFinishSSRSync | ||
useDidFinishSSR | ||
}); | ||
//# sourceMappingURL=index.js.map |
import * as React from "react"; | ||
const emptyFn = () => { | ||
}, emptyFnFn = () => emptyFn; | ||
function useDidFinishSSR(value, options) { | ||
if (options?.sync) | ||
return React.useSyncExternalStore( | ||
emptyFnFn, | ||
() => value ?? !0, | ||
() => !1 | ||
); | ||
function useDidFinishSSR(value) { | ||
const [cur, setCur] = React.useState(value); | ||
@@ -16,7 +8,2 @@ return React.useEffect(() => { | ||
} | ||
function useDidFinishSSRSync(value) { | ||
return useDidFinishSSR(value, { | ||
sync: !0 | ||
}); | ||
} | ||
function useClientValue(value) { | ||
@@ -27,5 +14,4 @@ return useDidFinishSSR() ? typeof value == "function" ? value() : value : void 0; | ||
useClientValue, | ||
useDidFinishSSR, | ||
useDidFinishSSRSync | ||
useDidFinishSSR | ||
}; | ||
//# sourceMappingURL=index.js.map |
import * as React from "react"; | ||
var emptyFn = function() { | ||
}, emptyFnFn = function() { | ||
return emptyFn; | ||
}; | ||
function useDidFinishSSR(value, options) { | ||
function useDidFinishSSR(value) { | ||
return value ?? !0; | ||
var cur, setCur; | ||
} | ||
function useDidFinishSSRSync(value) { | ||
return useDidFinishSSR(value, { | ||
sync: !0 | ||
}); | ||
} | ||
function useClientValue(value) { | ||
@@ -21,5 +12,4 @@ var done = useDidFinishSSR(); | ||
useClientValue, | ||
useDidFinishSSR, | ||
useDidFinishSSRSync | ||
useDidFinishSSR | ||
}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@tamagui/use-did-finish-ssr", | ||
"version": "1.115.5", | ||
"version": "1.116.0", | ||
"types": "./types/index.d.ts", | ||
@@ -32,3 +32,3 @@ "main": "dist/cjs", | ||
"devDependencies": { | ||
"@tamagui/build": "1.115.5", | ||
"@tamagui/build": "1.116.0", | ||
"react": "^18.2.0 || ^19.0.0" | ||
@@ -35,0 +35,0 @@ }, |
import * as React from 'react' | ||
const emptyFn = () => {} | ||
const emptyFnFn = () => emptyFn | ||
export function useDidFinishSSR<A = boolean>( | ||
value?: A, | ||
options?: { | ||
sync?: boolean | ||
} | ||
): A | false { | ||
export function useDidFinishSSR<A = boolean>(value?: A): A | false { | ||
if (process.env.TAMAGUI_TARGET === 'native') { | ||
@@ -17,10 +9,2 @@ // @ts-expect-error | ||
if (options?.sync) { | ||
return React.useSyncExternalStore( | ||
emptyFnFn, | ||
() => (value == undefined ? true : value), | ||
() => false as any | ||
) | ||
} | ||
const [cur, setCur] = React.useState<any>(value) | ||
@@ -33,11 +17,2 @@ React.useEffect(() => { | ||
// const useIsomorphicLayoutEffect = | ||
// typeof window === 'undefined' ? useEffect : useLayoutEffect | ||
export function useDidFinishSSRSync<A = boolean>(value?: A): A | false { | ||
return useDidFinishSSR(value, { | ||
sync: true, | ||
}) | ||
} | ||
type FunctionOrValue<Value> = Value extends () => infer X ? X : Value | ||
@@ -44,0 +19,0 @@ |
@@ -1,5 +0,2 @@ | ||
export declare function useDidFinishSSR<A = boolean>(value?: A, options?: { | ||
sync?: boolean; | ||
}): A | false; | ||
export declare function useDidFinishSSRSync<A = boolean>(value?: A): A | false; | ||
export declare function useDidFinishSSR<A = boolean>(value?: A): A | false; | ||
type FunctionOrValue<Value> = Value extends () => infer X ? X : Value; | ||
@@ -6,0 +3,0 @@ export declare function useClientValue<Value>(value?: Value): FunctionOrValue<Value> | undefined; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10486
152