rahul
rahul

Reputation: 151

Target container is not a DOM element while rendering

I am getting "Uncaught Invariant Violation: Target container is not a DOM element." while rendering in ReactJS.

ReactDOM.render(
<ApolloProvider client={client}>
    <App />
</ApolloProvider>,
<Router>
    <div>
        <Route exact path='/' component={App} />
        <Route path='/edit/:id' component={Edit} />
        <Route path='/create' component={Create} />
        <Route path='/show/:id' component={Show} />
    </div>
</Router>,
document.getElementById('root'));

This is how my code looks.

Upvotes: 0

Views: 382

Answers (1)

saurabh
saurabh

Reputation: 2713

ReactDOM.render(element, container[, callback])

Render a React element into the DOM in the supplied container and return a reference to the component (or returns null for stateless components). for more info

there are only two parameters for the render so you can wrap your code in a div

for example:

ReactDOM.render(
<div>
  <ApolloProvider client={client}>
    <App />
  </ApolloProvider>,
  <Router>
    <div>
        <Route exact path='/' component={App} />
        <Route path='/edit/:id' component={Edit} />
        <Route path='/create' component={Create} />
        <Route path='/show/:id' component={Show} />
    </div>
 </Router>
</div>,
document.getElementById('root'));

Upvotes: 1

Related Questions