Your music, beautifully tracked. All yours. (coming soon) teal.fm
teal-fm atproto
at fix-compose-path 12 lines 368 B view raw
1import React from "react"; 2 3// `useEffect` is not invoked during server rendering, meaning 4// we can use this to determine if we're on the server or not. 5export function useClientOnlyValue<S, C>(server: S, client: C): S | C { 6 const [value, setValue] = React.useState<S | C>(server); 7 React.useEffect(() => { 8 setValue(client); 9 }, [client]); 10 11 return value; 12}