Answer the question
In order to leave comments, you need to log in
Why is the React code not working?
Hello!
We started to learn React and almost immediately the question arose:
there are two files - Header.jsx and Submenu.jsx.
in header.jsx there is a container <div id="modalMenu"></div>
, in submenu, in fact, there is a container <div id="submenuContainer"></div>
.
what, in fact, is the question: I want to style the sub-menu container:
<div id="submenuContainer" style={{marginLeft: document.getElementById("modalMenu").scrollWidth}}></div>
import React from "react";
import Header from "./app/Header/Header";
import "./App.stylesheet.css";
import "./App.main.css";
import Submenu from "./app/Submenu/Submenu";
import Product from "./app/Modules/Product/Product"
import Loading from "./app/Loading/Loading"
class App extends React.Component {
render() {
return (
<div>
<header>
<Header />
</header>
<main id="content">
<Submenu />
<Product />
</main>
</div>
// <Loading />
);
}
}
export default App;
import React from "react";
import Menu from "./Menu/Menu";
import Logo from "./Logo/Logo";
import Controls from "./Controls/Controls";
import MenuContainer from "./Menu/MenuContainer";
class Header extends React.Component {
render() {
return (
<div className="header-container" id="headerContainer">
<div className="flex-row">
<div className="col-1-3"><Menu /></div>
<div className="col-1-3"><Logo /></div>
<div className="col-1-3"><Controls /></div>
</div>
<div className="modal-menu" id="modalMenu"><MenuContainer/></div>
</div>
);
}
}
export default Header;
import React from "react";
import Statistic from "./Sub-pages/Statistic";
import Products from "./Sub-pages/Products";
import Articles from "./Sub-pages/Articles";
import Sales from "./Sub-pages/Sales";
import Mediafiles from "./Sub-pages/Mediafiles";
import Delivery from "./Sub-pages/Delivery";
import Partners from "./Sub-pages/Partners";
import Suppliers from "./Sub-pages/Suppliers";
import Purchases from "./Sub-pages/Purchases"
class Submenu extends React.Component {
render() {
return (
<div className="submenu" id="submenuContainer" style={{marginLeft: document.getElementById("modalMenu").scrollWidth}}>
{/* <Statistic /> */}
{/* <Products /> */}
{/* <Articles /> */}
{/* <Sales /> */}
{/* <Mediafiles /> */}
{/* <Delivery /> */}
{/* <Partners /> */}
{/* <Suppliers /> */}
{/* <Purchases /> */}
</div>
);
}
}
export default Submenu;
Answer the question
In order to leave comments, you need to log in
React does not use id, it has its own react house tree, so you need to forget about id here. Now, as for the functionality, you need to study what props are, and swipe with them. Or if the components have a large chain, and you need to loop a lot, use redux mobx useState to choose from
What style are you trying to set? If you are already setting such a most strange indentation, then write like this:
<div id="submenuContainer" style={{marginLeft: {`${document.getElementById("modalMenu").scrollWidth}px`}}}></div>
modx+minishop2. This is if you want it simpler and don't plan a lot of products/options/filters.
Something more or less large and complex, Bitrix/CS-Cart.
Open cart 2 is just right for you . Free, simple architecture, the necessary functions are there, there are ready-made templates.
I strongly advise diafan.cms
tried a lot, free and paid boxed. eventually settled on diafan.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question