{
                  
                  
                          super(props);
                  
                  
                          this.state={isLoadingCategory:false,
                  
                  
                              Categories:{}};
                  
                  
                      
                  
                  
                      }
                  
                  
                      componentDidMount()
                  
                  
                      {
                  
                  
                          this.LoadCategories();  
                  
                  
                      }
                  
                  
                      LoadCategories()
                  
                  
                      {
                  
                  
                          this.setState({isLoadingCategory:false});
                  
                  
                          api("GET", "warehouse", "get-category",{id_owner:1, isOpen:true})
                  
                  
                          .then((result)=>
                  
                  
                          { 
                  
                  
                              this.setState({
                  
                  
                                  isLoadingCategory:true,
                  
                  
                                  Categories:result[0].children,
                  
                  
                                  })
                  
                  
                          })
                  
                  
                      }
                  
                  
                      render()
                  
                  
                      {
                  
                  
                          console.log(this.state.Categories);
                  
                  
                          const {isLoadingCategory, Categories} = this.state;
                  
                  
                          return(<Container>
                  
                  
                                  {isLoadingCategory && CategoryTree(Categories)}
                  
                  
                          </Container>);
                  
                  
                      }
                  
                  
                  }
                  
                  
                  
                  
                  
                  const CategoryTree = (Categories) => {
                  
                  
                      return (<ul>
                  
                  
                          {Categories.map((Category, key)=>
                  
                  
                              <li key={key}>
                  
                  
                                  {Category.children?
                  
                  
                                  (<div>{Category.name}{CategoryTree(Category.children)}</div>):
                  
                  
                                  (<div>{Category.name}</div>)}
                  
                  
                                  {ProductTree(Category.id)}
                  
                  
                              </li>)}
                  
                  
                      </ul>);
                  
                  
                  }
                  
                  
                  
                  
                  
                  const ProductTree = (id_category) => {
                  
                  
                      const [products, setProducts] = React.useState({});
                  
                  
                      return (<ul></ul>)
                  
                  
                  }
                  
                  
                  
                  
                  
                  export default Products;
                  
                  
                
Ты хук в класс-компоненте объявляешь. Переписывай
Обсуждают сегодня