import * as React from 'react';

export interface UseEnhancedOptions {
  clientSide: boolean;
  initial?: boolean;
}

export const useClientSide = (options: UseEnhancedOptions) => {
  const { clientSide: enhancedProp, initial = false } = options;
  const [enhanced, setEnhanced] = React.useState(initial);
  React.useEffect(() => {
    setEnhanced(enhancedProp);
  }, [enhancedProp]);

  return React.useMemo(() => ({
    clientSide: enhanced,
  }), [enhanced]);
};
