Taylor Gagne
Taylor Gagne

Reputation: 393

Meteor React render component to div inside main html file

I'm not really sure what is happening when the component tries to find the div, but here is my render and my div.

HTML:

<div id="app"></div>

Render function:

Meteor.startup(() => { ReactDOM.render(<App />, document.getElementById('app')); });

I get this error in the console: Error: Target container is not a DOM element.

I also put a console.log after my render function trying to find the div id but returned = null.

Upvotes: 3

Views: 157

Answers (2)

coagmano
coagmano

Reputation: 5671

What packages have you got installed?

if you've still got blaze-html-templates or templating, remove them both and replace with static-html

Otherwise Meteor will render the html as a blaze template some time after startup. (Also if you're using React, you probably don't want to ship Blaze to the client as well!)

Upvotes: 2

Yuting
Yuting

Reputation: 1

See http://archive.is/g20il#selection-399.104-399.186

Hard to see without your full html but your script tag to the .js script should be after the div id "app" tag.

Upvotes: 0

Related Questions