supermedium / aframe-react

:atom: Build virtual reality experiences with A-Frame and React.
https://ngokevin.github.io/aframe-react-boilerplate/
MIT License
1.42k stars 151 forks source link

Invoke .emit() on a ref for Animation? #16

Closed maxkrieger closed 8 years ago

maxkrieger commented 8 years ago

As from the docs, following this pattern:

<Entity ref="box" geometry="primitive: box" material="opacity: 1">
  <Animation attribute="material.opacity" begin="fade" to="2 2 2" />
</Entity>
this.refs.box.emit("fade");
Uncaught TypeError: _this.refs.box.emit is not a function

How does one properly implement this?

ngokevin commented 8 years ago

Hmm...isn't ref a callback nowadays? https://facebook.github.io/react/docs/more-about-refs.html#the-ref-callback-attribute

maxkrieger commented 8 years ago

Although the string method is outdated, it can still give you access to the domelement pretty easily.

ngokevin commented 8 years ago

Ah. So what does refs.box give you? Is that an <a-entity> DOM element?

maxkrieger commented 8 years ago

Oop, it gives an Entity :confused:. Is there a better way to implement this if any? screen shot 2016-02-16 at 15 10 39

ngokevin commented 8 years ago

I guess react-dom.findDOMNode

ngokevin commented 8 years ago

Somehow React should let you grab the DOM element, else write a component.