Files
umra-app/components/useClientOnlyValue.web.ts
Nurmuhammet Allanov 0072a1ed2a Initial commit
Generated by create-expo-app 3.5.1.
2025-08-16 19:40:32 +05:00

13 lines
368 B
TypeScript

import React from 'react';
// `useEffect` is not invoked during server rendering, meaning
// we can use this to determine if we're on the server or not.
export function useClientOnlyValue<S, C>(server: S, client: C): S | C {
const [value, setValue] = React.useState<S | C>(server);
React.useEffect(() => {
setValue(client);
}, [client]);
return value;
}