MCPcopy
hub / github.com/BetaSu/big-react / App

Function App

demos/transition/main.tsx:10–40  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8import './style.css';
9
10function 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
42const root = ReactDOM.createRoot(document.querySelector('#root'));
43

Callers

nothing calls this directly

Calls 3

useTransitionFunction · 0.90
useStateFunction · 0.90
selectTabFunction · 0.85

Tested by

no test coverage detected