@/utils#isServer TypeScript Examples

The following examples show how to use @/utils#isServer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: style.constant.ts    From mkn with MIT License 5 votes vote down vote up
CSS_THEME_DARK = isServer()
  ? __CSS_THEME_DARK__
  : getComputedStyle(document.documentElement)
      ?.getPropertyValue('--THEME--DARK')
      .trim() || __CSS_THEME_DARK__
Example #2
Source File: _app.tsx    From mkn with MIT License 5 votes vote down vote up
export default function CustomApp(props: ICustomApp) {
  const avoidCssAnimationFlashing = () => {
    if (!isServer()) {
      const disableTransitionDom = document.getElementById(
        DISABLE_SSR_TRANSITION,
      );

      if (disableTransitionDom) disableTransitionDom.remove();
    }
  };

  useEffect(() => {
    avoidCssAnimationFlashing();
  }, []);

  let layoutDom = null;

  if (props.pageProps?.layout === 'master') {
    layoutDom = (
      <MasterLayout
        mainComp={props.Component}
        routeProps={props.routeProps}
        pageProps={props.pageProps}
      />
    );
  }

  if (props.pageProps?.layout === 'test') {
    layoutDom = (
      <TestLayout
        mainComp={props.Component}
        routeProps={props.routeProps}
        pageProps={props.pageProps}
      />
    );
  }

  return (
    <ErrorBoundary>
      <HelmetProvider>
        {/* ⚠️⚠️⚠️ FK! Next.js does not support IconContext.Provider */}
        {/* <IconContext.Provider value={{ className: 'rcicon g-rcicon' }}> */}
        {layoutDom || <span />}
        {/* </IconContext.Provider> */}
      </HelmetProvider>
    </ErrorBoundary>
  );
}