Created
February 15, 2019 04:23
-
-
Save Youngestdev/5f41ab6afc0d4f7f3a6898e671293594 to your computer and use it in GitHub Desktop.
Actually, messing around unethical ideas and sketching rough codes.
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, { useEffect, useContext, useRef } from 'react'; | |
| export const NodeMounter = props => { | |
| const ref = useRef(''); | |
| const { node } = props; | |
| ref.appendChild(node); | |
| useEffect(( {node: prevNode} ) => { | |
| const { node } = props; | |
| ref.current.removeChild(prevNode); | |
| ref.current.appendChild(node); | |
| return () => { | |
| const { node } = props; | |
| ref.current.removeChild(node); | |
| } | |
| }); | |
| return <g ref={ref} />; | |
| }; | |
| export const RoughContext = React.createContext(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Still learning how to write hooks. Sadly, I wrote this ( pardon me if it's bad code, I fore apologise ): Anyways, here is the
ReactRoughcomponent. But, test doesn't pass 😢 . The reason the test doesn't pass is because there's smtn I'm not doing right in the Context Consumer-Provider API.