Skip to content

Instantly share code, notes, and snippets.

@jimbol
Created October 5, 2017 15:26
Show Gist options
  • Save jimbol/cf701b29be4999c4fd7ab316e25dc3ca to your computer and use it in GitHub Desktop.
Save jimbol/cf701b29be4999c4fd7ab316e25dc3ca to your computer and use it in GitHub Desktop.
Passing a component as a prop
import { UserComp, OtherPersonComp } from './components';
const PersonComp = ({ InnerComp, person }) => {
return <section>
<InnerComp person={person}>
</section>;
}
const mapState = (state) => ({
InnerComp: state.person.isUser ? UserComp : OtherPersonComp,
person: state.selectedPerson,
});
export const LinkedPersonComp = connect(mapState)(PersonComp);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment