()
| 8 | import './style.css'; |
| 9 | |
| 10 | function App() { |
| 11 | const [isPending, startTransition] = useTransition(); |
| 12 | const [tab, setTab] = useState('about'); |
| 13 | console.log('hello'); |
| 14 | function selectTab(nextTab) { |
| 15 | startTransition(() => { |
| 16 | setTab(nextTab); |
| 17 | }); |
| 18 | } |
| 19 | |
| 20 | return ( |
| 21 | <> |
| 22 | <TabButton isActive={tab === 'about'} onClick={() => selectTab('about')}> |
| 23 | 首页 |
| 24 | </TabButton> |
| 25 | <TabButton isActive={tab === 'posts'} onClick={() => selectTab('posts')}> |
| 26 | 博客 (render慢) |
| 27 | </TabButton> |
| 28 | <TabButton |
| 29 | isActive={tab === 'contact'} |
| 30 | onClick={() => selectTab('contact')} |
| 31 | > |
| 32 | 联系我 |
| 33 | </TabButton> |
| 34 | <hr /> |
| 35 | {tab === 'about' && <AboutTab />} |
| 36 | {tab === 'posts' && <PostsTab />} |
| 37 | {tab === 'contact' && <ContactTab />} |
| 38 | </> |
| 39 | ); |
| 40 | } |
| 41 | |
| 42 | const root = ReactDOM.createRoot(document.querySelector('#root')); |
| 43 |
nothing calls this directly
no test coverage detected