itizawa 5 лет назад
Родитель
Сommit
3076d06680
1 измененных файлов с 7 добавлено и 13 удалено
  1. 7 13
      src/client/js/components/PageAccessoriesModal.jsx

+ 7 - 13
src/client/js/components/PageAccessoriesModal.jsx

@@ -63,11 +63,13 @@ const PageAccessoriesModal = (props) => {
   const { activeTab } = pageAccessoriesContainer.state;
   const { activeTab } = pageAccessoriesContainer.state;
 
 
   const sliderEl = useRef(null);
   const sliderEl = useRef(null);
-  const navLinkEls = useRef([]);
+  const navTitle = document.getElementById('nav-title');
+  const navTabs = document.querySelectorAll('li.nav-link');
 
 
-  navTabMapping.forEach((data, i) => {
-    navLinkEls.current[i] = React.createRef();
-  });
+  function changeFlexibility(width, tempMarginLeft) {
+    sliderEl.current.width = `${width}%`;
+    sliderEl.current.style.marginLeft = `${tempMarginLeft}%`;
+  }
 
 
   function closeModalHandler() {
   function closeModalHandler() {
     if (props.onClose == null) {
     if (props.onClose == null) {
@@ -76,19 +78,11 @@ const PageAccessoriesModal = (props) => {
     props.onClose();
     props.onClose();
   }
   }
 
 
-  const navTitle = document.getElementById('nav-title');
-  const navTabs = document.querySelectorAll('li.nav-link');
-
   // Might make this dynamic for px, %, pt, em
   // Might make this dynamic for px, %, pt, em
   function getPercentage(min, max) {
   function getPercentage(min, max) {
     return min / max * 100;
     return min / max * 100;
   }
   }
 
 
-  function changeFlexibility(width, tempMarginLeft) {
-    sliderEl.current.width = `${width}%`;
-    sliderEl.current.style.marginLeft = `${tempMarginLeft}%`;
-  }
-
   const fetchSize = useCallback(() => {
   const fetchSize = useCallback(() => {
     return [].map.call(navTabs, (el) => {
     return [].map.call(navTabs, (el) => {
       const width = getPercentage(el.offsetWidth, navTitle.offsetWidth);
       const width = getPercentage(el.offsetWidth, navTitle.offsetWidth);
@@ -125,7 +119,7 @@ const PageAccessoriesModal = (props) => {
             {navTabMapping.map((tab, index) => {
             {navTabMapping.map((tab, index) => {
               return (
               return (
                 <NavItem key={tab.id} type="button" className={`nav-link ${activeTab === tab.id && 'active'}`}>
                 <NavItem key={tab.id} type="button" className={`nav-link ${activeTab === tab.id && 'active'}`}>
-                  <NavLink innerRef={navLinkEls.current[index]} onClick={() => { switchActiveTab(tab.id) }}>
+                  <NavLink onClick={() => { switchActiveTab(tab.id) }}>
                     {tab.icon}
                     {tab.icon}
                     {t(tab.i18n)}
                     {t(tab.i18n)}
                   </NavLink>
                   </NavLink>