|
1 | 1 | import React, { useCallback, useState } from 'react'; |
2 | | -import TreeView from 'devextreme-react/tree-view'; |
3 | 2 | import TabPanel from 'devextreme-react/tab-panel'; |
| 3 | +import TreeView from 'devextreme-react/tree-view'; |
4 | 4 | import { continents } from './data.js'; |
5 | 5 |
|
6 | 6 | const renderPanelItemTitle = (item) => <span className="tab-panel-title">{item.text}</span>; |
7 | 7 | const renderPanelItem = (city) => ( |
8 | | - <React.Fragment> |
| 8 | + <> |
9 | 9 | <img |
10 | 10 | alt="country flag" |
11 | 11 | className="flag" |
@@ -41,29 +41,23 @@ const renderPanelItem = (city) => ( |
41 | 41 | </div> |
42 | 42 | </div> |
43 | 43 | </div> |
44 | | - </React.Fragment> |
| 44 | + </> |
45 | 45 | ); |
46 | 46 | function App() { |
47 | 47 | const [tabPanelIndex, setTabPanelIndex] = useState(0); |
48 | 48 | const [countryData, setCountryData] = useState(continents[0].items[0]); |
49 | 49 | const [citiesData, setCitiesData] = useState(continents[0].items[0].cities); |
50 | | - const handleTreeViewSelectionChange = useCallback( |
51 | | - (e) => { |
52 | | - const selectedCountryData = e.itemData; |
53 | | - if (selectedCountryData.cities) { |
54 | | - setTabPanelIndex(0); |
55 | | - setCountryData(selectedCountryData); |
56 | | - setCitiesData(selectedCountryData.cities); |
57 | | - } |
58 | | - }, |
59 | | - [setTabPanelIndex, setCountryData, setCitiesData], |
60 | | - ); |
61 | | - const handleTabPanelSelectionChange = useCallback( |
62 | | - (e) => { |
63 | | - setTabPanelIndex(e.value); |
64 | | - }, |
65 | | - [setTabPanelIndex], |
66 | | - ); |
| 50 | + const handleTreeViewSelectionChange = useCallback((e) => { |
| 51 | + const selectedCountryData = e.itemData; |
| 52 | + if (selectedCountryData.cities) { |
| 53 | + setTabPanelIndex(0); |
| 54 | + setCountryData(selectedCountryData); |
| 55 | + setCitiesData(selectedCountryData.cities); |
| 56 | + } |
| 57 | + }, []); |
| 58 | + const handleTabPanelSelectionChange = useCallback((e) => { |
| 59 | + setTabPanelIndex(e.value); |
| 60 | + }, []); |
67 | 61 | return ( |
68 | 62 | <div className="container"> |
69 | 63 | <div className="left-content"> |
|
0 commit comments