#49 ちょろちょろ
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
|
||||
type Props = { tabs: { [key: string]: React.ReactNode }
|
||||
init?: string }
|
||||
|
||||
|
||||
export default ({ tabs, init }: Props) => {
|
||||
const [current, setCurrent] = useState<string> (init
|
||||
?? Object.keys (tabs)?.[0]
|
||||
?? '')
|
||||
|
||||
return (
|
||||
<div className="mt-4">
|
||||
{Object.entries (tabs).map (([name, element]) => (
|
||||
<a href="#"
|
||||
className="text-blue-400 hover:underline cursor-pointer"
|
||||
onClick={(event) => {
|
||||
event.preventDefault ()
|
||||
setCurrent (name)
|
||||
}}>
|
||||
{name}
|
||||
</a>))}
|
||||
{current && tabs[current]}
|
||||
</div>)
|
||||
}
|
||||
Reference in New Issue
Block a user