This file contains 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
let amplitude: any; | |
let ga: any; | |
function WithLogging({ | |
action, | |
eventName, | |
children, | |
}: { | |
action: 'view' | 'click' | 'focus'; | |
eventName: string; |
This file contains 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 Page() { | |
return ( | |
<Layout> | |
{/* Tab의 상태는 WithTab 내부로 추상화 */} | |
<WithTab items={tabItems}> | |
{selectedTab => { | |
switch (selectedTab) { | |
case 'LOGIN': | |
return <Login /> | |
case 'JOIN': |
This file contains 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
// Tabs.jsx | |
import React from 'react' | |
function Tabs({ children }) { | |
const [selectedTab, setTab] = React.useState(initialTab) | |
return ( | |
<ul className="tab-container"> | |
{children(selectedTab, setTab)} | |
</ul> |
This file contains 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
// 일반 컴포넌트 | |
<Button> | |
눌러주세요 | |
</Button> | |
// Render Props 컴포넌트 | |
<Button> | |
{() => <>눌러주세요</>} | |
</Button> |
This file contains 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
// Tabs.jsx | |
import React from 'react' | |
const TabContext = React.createContext() | |
function Tabs({ children }) { | |
const [selectedTab, setTab] = React.useState(initialTab) | |
return ( | |
<TabContext.Provider value={{ selectedTab, setTab }}> |
This file contains 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
<select> | |
<option>당근</option> | |
<option>양파</option> | |
<option>마늘</option> | |
<option>배추</option> | |
<option>오이</option> | |
</select> |
This file contains 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
// Tabs.js | |
import React from 'react' | |
function Tabs({ children }) { | |
const [selectedTab, setTab] = React.useState(initialTab) | |
return ( | |
<ul className="tab-container"> | |
{React.Children.map(children, child => ( | |
React.cloneElement(child, { |
This file contains 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 Page() { | |
return ( | |
<Tabs> | |
{tabItems.map(tabItem => ( | |
<Tabs.Item value={tabItem}> | |
{tabItem} | |
</Tabs.Item> | |
))} | |
</Tabs> | |
) |
This file contains 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 Page() { | |
const [selectedTab, setTab] = React.useState(initialTab) | |
return ( | |
<Tabs> | |
{tabItems.map(tabItem => ( | |
<Tabs.Item | |
value={tabItem} | |
isSelected={selectedTab === tabItem} | |
onSelect={setTab} |
This file contains 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 Page() { | |
const [tab, setTab] = React.useState(initialTab) | |
return ( | |
<Tabs | |
items={tabItems} | |
onSelectTab={setTab} | |
selectedTab={tab} | |
/> | |
) |
NewerOlder