Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

213
Views
Object placement of app that contains provider which stores all the state (React)

I'm trying to make an authentication on django-react web and came across this tutorial on youtube https://www.youtube.com/watch?v=BxzO2M7QcZw&t=2907s There is an object called app that contain provider which wrap a components and define a store. In that tutorial, app is called inside render function in index.js file. Below is the code

const app = (
    <Provider store={store}>
        <App />
    </Provider>
)

ReactDOM.render(app, document.getElementById('root'));
registerServiceWorker();

I'm trying to follow this tutorial but i have a different format of index.js because i create all my routing path inside it while the tutorial create the route inside app.js. My question is, where should i put the app object if i have a code like this inside my index.js file?

const composeEnhances = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose

const store = createStore(reducer, composeEnhances(
    applyMiddleware(thunk)
));

const app = (
    <Provider store={store}>
        <Homepage></Homepage>
        <SportsSearch></SportsSearch>
    </Provider>
)

const sports_dict = ['futsal', 'badminton', 'basket', 'sepak-bola', 'voli', 'tenis', 'billiard', 'tenis-meja']

render(
  <BrowserRouter>
    <Routes>
    <Route path="/" element={<Homepage />} />
        <Route path="/R1" element={<RecommendationOne />} />

        {sports_dict.map(sport => {
            return (
                <Route path={`/${sport}`} element={<SportsSearch variable={sport} />} />

            )
        })}
    </Routes>
  </BrowserRouter>,
  document.getElementById("root")
);

I have tried to put my app inside render but i get an error of Error: Target container is not a DOM element. below code is what i've tried

render(
  app,
  <BrowserRouter>
    <Routes>
    <Route path="/" element={<Homepage />} />
        <Route path="/R1" element={<RecommendationOne />} />

        {sports_dict.map(sport => {
            return (
                <Route path={`/${sport}`} element={<SportsSearch variable={sport} />} />

            )
        })}
    </Routes>
  </BrowserRouter>,
  document.getElementById("root")
);
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!