Created
June 25, 2020 12:41
-
-
Save velotiotech/1513588cfe89980eed86495ed25ca331 to your computer and use it in GitHub Desktop.
Cleaner Efficient Code with Hooks and Functional Programming - Fixing Wrapper Hell with hooks - Render props replaced by custom hooks
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"; | |
import useMedia from "./hooks/useMedia"; | |
function App() { | |
let small = useMedia("(max-width: 480px)"); | |
let large = useMedia("(min-width: 1024px)"); | |
return ( | |
<div className="media"> | |
<h1>Media</h1> | |
<p>{small ? "small screen" : "not a small screen"}</p> | |
<p>{large ? "large screen" : "not a large screen"}</p> | |
</div> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment