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.

Revisions

  1. kwoncharles created this gist Dec 24, 2020.
    43 changes: 43 additions & 0 deletions Page.jsx
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    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>
    )
    }