aframe-react icon indicating copy to clipboard operation
aframe-react copied to clipboard

Support server-side universal/isomorphic

Open ngokevin opened this issue 8 years ago • 5 comments

Currently tied to AFRAME.components. Can't include A-Frame because of window.

https://github.com/aframevr/aframe/issues/2031

ngokevin avatar Oct 31 '16 18:10 ngokevin

@ngokevin I have created a repo https://github.com/ltfschoen/react-fluxible-test that shows how to incorporate A-Frame React into a Fluxible app (i.e. uses isomorphic architecture with server-side rendering)

ltfschoen avatar Feb 04 '17 08:02 ltfschoen

@ltfschoen Nice! Can you give a brief description how you were able to get it to work?

ngokevin avatar Feb 06 '17 23:02 ngokevin

@ngokevin

  • I followed the instructions at http://fluxible.io/quick-start.html to generate a boilerplate Fluxible app.
  • I installed the aframe, aframe-react, and exenv npm packages.
  • I imported aframe in client.js (client-side global document where the window object is available)
  • I conditionally render the aframe-react components after the DOM is available (i.e. window) with the help of canUseDOM from the exenv library https://github.com/JedWatson/exenv

ltfschoen avatar Feb 07 '17 03:02 ltfschoen

With v4.0.x, A-Frame doesn't use AFRAME necessarily. But it uses A-Frame's .setAttribute()s now, which won't work as well server-side. Need to think about this more.

ngokevin avatar Mar 27 '17 04:03 ngokevin

@ngokevin looks like setAttribute is only used on componentDidMount and componentDidUpdate which are after mount, so i think that part should be ok (since only the componentWillMount lifecycle function is called server-side)

jhsu avatar Apr 03 '17 17:04 jhsu