Skip to content

Instantly share code, notes, and snippets.

Created June 25, 2020 12:41
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Cleaner Efficient Code with Hooks and Functional Programming - Fixing Wrapper Hell with hooks - Render props replaced by custom hooks
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">
<p>{small ? "small screen" : "not a small screen"}</p>
<p>{large ? "large screen" : "not a large screen"}</p>
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment