Created
September 8, 2019 17:42
-
-
Save crazypixel/229258fcdc12b9da467235c5ba0a3418 to your computer and use it in GitHub Desktop.
use memo for styles
This file contains 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
const styles = useMemo(() => ({ | |
cursor: state.isDragging ? '-webkit-grabbing' : '-webkit-grab', | |
transform: `translate(${state.translation.x}px, ${state.translation.y}px)`, | |
transition: state.isDragging ? 'none' : 'transform 500ms', | |
zIndex: state.isDragging ? 2 : 1, | |
position: state.isDragging ? 'absolute' : 'relative' | |
}), [state.isDragging, state.translation]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment