Skip to content

Instantly share code, notes, and snippets.

@kwoncharles
Created December 24, 2020 00:35
Show Gist options
  • Save kwoncharles/7b8ee145d09af5e9076e18f5fb6860ec to your computer and use it in GitHub Desktop.
Save kwoncharles/7b8ee145d09af5e9076e18f5fb6860ec to your computer and use it in GitHub Desktop.
You might need render props
function Page() {
return (
<Layout>
{/* Tab의 상태는 WithTab 내부로 추상화 */}
<WithTab items={tabItems}>
{selectedTab => {
switch (selectedTab) {
case 'LOGIN':
return <Login />
case 'JOIN':
return <Join />
case 'HOME':
default:
return <Home />
}
}}
</WithTab>
</Layout>
)
}
// 꼭 children으로만 함수를 전달할 필요는 없습니다 :)
function Page() {
return (
<Layout>
<WithTab
items={tabItems}
renderContent={selectedTab => {
switch (selectedTab) {
case 'LOGIN':
return <Login />
case 'JOIN':
return <Join />
case 'HOME':
default:
return <Home />
}
}}
/>
</Layout>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment