Your music, beautifully tracked. All yours. (coming soon)
teal.fm
teal-fm
atproto
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}