Created
February 25, 2020 14:45
-
-
Save fivethreeo/8527ff4c7b73913b6d6b55204be60c4b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useLayoutEffect } from 'react'; | |
// eslint-disable-next-line max-len | |
// See https://github.com/reduxjs/react-redux/blob/316467a/src/hooks/useSelector.js#L6-L15 | |
export const useIsomorphicLayoutEffect = | |
typeof window !== 'undefined' ? useLayoutEffect : useEffect; | |
export const useServerNoopLayoutEffect = | |
typeof window !== 'undefined' ? useLayoutEffect : () => ({}); | |
export const useServerNoopEffect = | |
typeof window !== 'undefined' ? useEffect : () => ({}); | |
export const useClientNoopEffect = | |
typeof window !== 'undefined' ? () => ({}) : useEffect; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment