Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Bwithnewcast

React.js Target container is not a DOM element.

Recommended Posts

Posted · Original PosterOP

The code: https://github.com/Bwithnewcast/Website_project/tree/master/

 

I am coding in codesandbox.

 

The error message i am getting:

 

Invariant Violation: Target container is not a DOM element.

at invariant (https://jzpx40y283.codesandbox.io/node_modules/react-dom/cjs/react-dom.development.js:55:15) at Object.render (https://jzpx40y283.codesandbox.io/node_modules/react-dom/cjs/react-dom.development.js:21151:36) at evaluate (https://jzpx40y283.codesandbox.io/src/index.js:13:19) at ue (https://codesandbox.io/static/js/sandbox.2d465eb5.js:1:162757) at e.value (https://codesandbox.io/static/js/sandbox.2d465eb5.js:1:177330) at e.value (https://codesandbox.io/static/js/sandbox.2d465eb5.js:1:205633) at t (https://codesandbox.io/static/js/sandbox.2d465eb5.js:1:177072) at loadResources (https://jzpx40y283.codesandbox.io/src/index.html:5:2) at evaluate (https://jzpx40y283.codesandbox.io/src/index.html:11:3) at ue (https://codesandbox.io/static/js/sandbox.2d465eb5.js:1:162757) at e.value (https://codesandbox.io/static/js/sandbox.2d465eb5.js:1:177330) at e.value (https://codesandbox.io/static/js/sandbox.2d465eb5.js:1:205633) at e.value (https://codesandbox.io/static/js/sandbox.2d465eb5.js:1:205214) at https://codesandbox.io/static/js/sandbox.2d465eb5.js:1:101429 at g (https://codesandbox.io/static/js/common-sandbox.3445291d.chunk.js:1:387899) at Generator._invoke (https://codesandbox.io/static/js/common-sandbox.3445291d.chunk.js:1:387687) at Generator.e.(anonymous function) [as next] (https://codesandbox.io/static/js/common-sandbox.3445291d.chunk.js:1:388078) at t (https://codesandbox.io/static/js/common-sandbox.3445291d.chunk.js:1:379157) at u (https://codesandbox.io/static/js/common-sandbox.3445291d.chunk.js:1:379367)

Link to post
Share on other sites

TaskBar() is a function, not a React Component, that you could render.

 

EDIT: Example from official docs

class HelloMessage extends React.Component {
  render() {
    return (
      <div>
        Hello {this.props.name}
      </div>
    );
  }
}

ReactDOM.render(
  <HelloMessage name="Taylor" />,
  document.getElementById('hello-example')
);

Skynet: MacBook Pro Late 2016 Space Gray | i7-6820HQ 2.7 GHz | 16 GB LPDDR3 | Radeon Pro 455 2048 MB | 512 GB NVMe SSD | 15" 2880x1800

HAL9000: Intel i5-9600k | Cryorig M9 | 16 GB Corsair Vengeance LPX DDR4 3200 MHz | Gigabyte Z390I AORUS PRO WIFI | Zotac GTX 1080Ti Mini | 256 GB Samsung 850 Pro + 1 TB Crucial MX500 | Corsair TX650M | Cougar QBX | LG 34UM95 34" 3440x1440

Hydrogen server: Xeon E5-2675 v3 | Cooler Master Hyper 212X | 64 GB Kingston/Samsung DDR4 ECC | Asus Z10PA-D8 | Corsair AX860 | 256 GB Samsung 850 Evo + 3x 3 TB WD Red + 2 TB Seagate | Fractal Design Define R5 | unRAID 6.6.6

Carbon server: Fujitsu PRIMERGY RX100 S7p | Xeon E3-1230 v2 | 16 GB DDR3 ECC | 60 GB Corsair SSD & 250 GB Samsung 850 Pro | Intel i340-T4 | ESXi 6.5.1

Big Mac cluster: 2x Raspberry Pi 2 Model B | 1x Raspberry Pi 3 Model B | 2x Raspberry Pi 3 Model B+

Link to post
Share on other sites
Posted · Original PosterOP
1 hour ago, jj9987 said:

TaskBar() is a function, not a React Component, that you could render.

 

EDIT: Example from official docs


class HelloMessage extends React.Component {
  render() {
    return (
      <div>
        Hello {this.props.name}
      </div>
    );
  }
}

ReactDOM.render(
  <HelloMessage name="Taylor" />,
  document.getElementById('hello-example')
);

Even if i do it with this method i still get the "Target container is not a DOM element." error

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Buy VPN

×