Created
January 12, 2020 09:32
-
-
Save emmabostian/4bf99348e7cd40ca8d017a1fe4c1bfeb 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, { useState } from "react"; | |
import ReactDOM from "react-dom"; | |
import { useSpring } from "react-spring" | |
import { MenuRight } from "./Menu"; | |
import "./styles.css"; | |
function App() { | |
const [ rightMenuVisible, setRightMenuVisible ] = useState(false); | |
const rightMenuAnimation = useSpring({ | |
opacity: rightMenuVisible ? 1 : 0, | |
transform: rightMenuVisible ? `translateX(0)` : `translateX(100%)` | |
}); | |
return ( | |
<div className="App"> | |
<button | |
className="menu-button" | |
onClick={() => setRightMenuVisible(!rightMenuVisible)} | |
> | |
{rightMenuVisible ? "Close" : "Side Menu"} | |
</button> | |
<MenuRight style={rightMenuAnimation} /> | |
</div> | |
); | |
} | |
const rootElement = document.getElementById("root"); | |
ReactDOM.render(<App />, rootElement); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment