Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

THREE error when returning null in a render method #37

Open
fredericlb opened this issue Sep 18, 2015 · 1 comment
Open

THREE error when returning null in a render method #37

fredericlb opened this issue Sep 18, 2015 · 1 comment
Assignees

Comments

@fredericlb
Copy link

When a custom component in a scene returns null on render (i'm currently writing a Mesh component that waits for its content to be loaded before display), THREE.js fails with :

THREE.Object3D.add: <noscript data-reactid="undefined.1"></noscript> is not an instance of THREE.Object3D.

Which is right since React replaces the value with a noscript tag when null is returned by a component. react-three should check for this behaviour but I haven't found a clean way to do this.
For now I just check if the string is a noscript tag but it is not reliable (and really dirty).

Could someone who knows React internals provide some hints on this subject ?

@Izzimach Izzimach self-assigned this Sep 18, 2015
@Izzimach
Copy link
Owner

In react/lib/ReactDefaultInjection.js there is this:

ReactInjection.EmptyComponent.injectEmptyComponent('noscript');

I suppose I could override that and make the default empty component into a blank Object3D node, but then you could no longer render null DOM elements.

A more robust method is to check elements just before instantiating them and replacing null with an empty THREE Object3D. For now, you can workaround this by returning an empty Object3D instead of null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants