Skip to content

Instantly share code, notes, and snippets.

@alfrescian
Last active April 24, 2019 07:48
Show Gist options
  • Select an option

  • Save alfrescian/ff503c9ce21e51624e08619b02a19edc to your computer and use it in GitHub Desktop.

Select an option

Save alfrescian/ff503c9ce21e51624e08619b02a19edc to your computer and use it in GitHub Desktop.
highlight component when (re-)rendered
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