Last active
April 24, 2019 07:48
-
-
Save alfrescian/ff503c9ce21e51624e08619b02a19edc to your computer and use it in GitHub Desktop.
highlight component when (re-)rendered
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 React from "react"; | |
| export default function Flash({ type, ...props }) { | |
| const elRef = React.useRef(); | |
| React.useEffect(() => { | |
| window.requestAnimationFrame(() => { | |
| elRef.current.style["box-shadow"] = "0 0 0 2px red"; | |
| elRef.current.style["transition"] = "none"; | |
| window.requestAnimationFrame(() => { | |
| elRef.current.style["box-shadow"] = "0 0 0 2px transparent"; | |
| elRef.current.style["transition"] = "all 2s ease"; | |
| }); | |
| }); | |
| }); | |
| return React.createElement(type, { ref: elRef, ...props }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment