Izzimach / react-three-legacy

React bindings to create and control a 3D scene using three.js
Other
1.52k stars 127 forks source link

requiring react-three prevents components from rerendering #14

Closed sebastianmenge closed 9 years ago

sebastianmenge commented 9 years ago

hey, i'm encountering another problem. it is pretty weird. as soon as i require react-three in in some jsx component like in the code below, no rerenders on state changes are happening at all anymore. only the initial render is taking place. thought it could be react-router but that doesnt seem to be the problem either.

var React = require("react"),
    ReactTHREE = require('react-three'),
    THREE = require('three'),
Izzimach commented 9 years ago

I dunno, that should work.

Does it work if you replace the JSX with javascript? Does the jsxtransform.jsx example work? Can you maybe put up a gist and reference it here?

sebastianmenge commented 9 years ago

doesn't make difference if i use javascript or jsx. both is not working but the jsx example works fine for me.

here is the gist: https://gist.github.com/sebastianmenge/07723e62ca78081176b7

as soon as i require and use the Canvas component which requires react-three, all parents of canvas only do the initial render except the canvas component itself. it updates normally.

have you used webpack with react-three? maybe thats an issue.

Izzimach commented 9 years ago

I've not used webpack before, so it's possible.

Well, react-three does some monkey-patching of React in order to fix certain problems like this one. There may be some wierd interaction between the monkey-patch and webpack that causes this.

You can try to comment out this line in ReactTHREE.js to see if it fixes the problem. If that's the problem I'll have to come up with some other way to 'fix' React

sebastianmenge commented 9 years ago

commenting the line fixed the problem.

Izzimach commented 9 years ago

Hm, well that needs to be fixed. Adding #15