Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SSR wrapper for useLayoutEffect #59

Open
joduplessis opened this issue May 26, 2024 · 1 comment
Open

Add SSR wrapper for useLayoutEffect #59

joduplessis opened this issue May 26, 2024 · 1 comment
Labels
needs more info Improvements or additions to documentation

Comments

@joduplessis
Copy link
Member

https://medium.com/@alexandereardon/uselayouteffect-and-ssr-192986cdcf7a

import useLayoutEffect from './use-isomorphic-layout-effect';
function App() {
  useLayoutEffect(() => {
    console.log('hello there');
  }, []);
  return 'Hello world';
};
// use-isomorphic-layout-effect.js
import { useLayoutEffect, useEffect } from 'react';
const useIsomorphicLayoutEffect =
  typeof window !== 'undefined' ? useLayoutEffect : useEffect;
export default useIsomorphicLayoutEffect;
@joduplessis joduplessis added the needs more info Improvements or additions to documentation label May 27, 2024
@joduplessis
Copy link
Member Author

This doesn't appear to be an immediate issue if you use use client in NextJS.

@joduplessis joduplessis transferred this issue from fold-dev/fold May 29, 2024
@joduplessis joduplessis removed the core label Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info Improvements or additions to documentation
Projects
Status: Todo
Development

No branches or pull requests

1 participant