Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Last active June 25, 2020 12:39
Show Gist options
  • Save velotiotech/456b79d8681cbc894af6c186461f4a46 to your computer and use it in GitHub Desktop.
Save velotiotech/456b79d8681cbc894af6c186461f4a46 to your computer and use it in GitHub Desktop.
Cleaner Efficient Code with Hooks and Functional Programming - Wrapper Hell issue - Typical render props usage
import React from "react";
import Media from "./components/Media";
function App() {
return (
<Media query="(max-width: 480px)">
{small => (
<Media query="(min-width: 1024px)">
{large => (
<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>
)}
</Media>
)}
</Media>
);
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment