File tree Expand file tree Collapse file tree 1 file changed +14
-18
lines changed Expand file tree Collapse file tree 1 file changed +14
-18
lines changed Original file line number Diff line number Diff line change @@ -274,24 +274,20 @@ In this mode react-tabs does not handle any tab selection state internally and l
274
274
This mode also enforces you to set a handler for ` onSelect` . ` defaultIndex` does not have any effect and will therefore throw an error.
275
275
276
276
` ` ` js
277
- class App extends Component {
278
- constructor () {
279
- super ();
280
- this .state = { tabIndex: 0 };
281
- }
282
- render () {
283
- return (
284
- < Tabs selectedIndex= {this .state .tabIndex } onSelect= {tabIndex => this .setState ({ tabIndex })}>
285
- < TabList>
286
- < Tab> Title 1 < / Tab>
287
- < Tab> Title 2 < / Tab>
288
- < / TabList>
289
- < TabPanel>< / TabPanel>
290
- < TabPanel>< / TabPanel>
291
- < / Tabs>
292
- );
293
- }
294
- }
277
+ const App = () => {
278
+ const [tabIndex , setTabIndex ] = useState (0 );
279
+
280
+ return (
281
+ < Tabs selectedIndex= {tabIndex} onSelect= {index => setTabIndex (index)}>
282
+ < TabList>
283
+ < Tab> Title 1 < / Tab>
284
+ < Tab> Title 2 < / Tab>
285
+ < / TabList>
286
+ < TabPanel>< / TabPanel>
287
+ < TabPanel>< / TabPanel>
288
+ < / Tabs>
289
+ );
290
+ };
295
291
` ` `
296
292
297
293
## Styling
You can’t perform that action at this time.
0 commit comments