Created
April 15, 2021 11:19
-
-
Save Saspian/f870ca4699f70b7205245c3db5b1573d to your computer and use it in GitHub Desktop.
Example of Render props
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 from "react"; | |
import SpeakersRenderProps from "./SpeakersRenderProps"; | |
const Speakers = () => { | |
return ( | |
<SpeakersRenderProps> | |
{({speakers}) => { | |
return ( | |
<div> | |
{speakers.map(({ name, address })=> { | |
return <h1>{name, address}</h1> | |
}) | |
</div> | |
); | |
}} | |
</SpeakersRenderProps> | |
) | |
} | |
export default Speakers; |
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
function SpeakersRenderProps(props) { | |
const speakers = [ | |
{name: "Sanjay gurung", address: "kathmandu" }, | |
{name: "Sirish gurung", address: "Patan" }, | |
{name: "Abhinab gurung", address: "Patan" }, | |
]; | |
return props.children({ | |
speakers: speakers | |
}); | |
} | |
export default SpeakersRenderProps; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment