Last active
June 28, 2020 14:58
-
-
Save ilyalesik/c0f7393f15856de7296249f987f19c18 to your computer and use it in GitHub Desktop.
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
import React from "react"; | |
const LoadingWrapper = (props) => { | |
const {as, loading, ...otherProps} = props; | |
const el = React.useRef(); | |
React.useEffect(() => { | |
el.current && el.current.setAttribute("loading", loading); | |
}, [loading]); | |
const Component = as; | |
return <Component ref={el} {...otherProps} /> | |
} | |
... | |
<LoadingWrapper as={"div"} loading={...} /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment