Skip to content

Instantly share code, notes, and snippets.

@prof3ssorSt3v3
Created October 13, 2018 20:39
Show Gist options
  • Save prof3ssorSt3v3/ea3151d540af67a2101c4a4e0e700834 to your computer and use it in GitHub Desktop.
Save prof3ssorSt3v3/ea3151d540af67a2101c4a4e0e700834 to your computer and use it in GitHub Desktop.
import React, {Component, Fragment} from 'react';
import BigBrother from './BigBrother';
import LittleSister from './LittleSister';
import LittleBrother from './LittleBrother';
export default class Parent extends Component{
/****
A component with a render prop takes a function
that returns a React element and calls it
instead of implementing its own render logic.
A common practice is to call it render but the prop
can be whatever you want.
****/
render(){
return (
<Fragment>
<BigBrother copycat={ (brother) => (
<Fragment>
<LittleSister bgcolor="pink" brother={brother} />
<LittleBrother bgcolor="skyblue" brother={brother} />
</Fragment>
)}/>
</Fragment>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment