question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Primitives turn into geometry={{primitive:box}} when updating any geometry attribute with react state

See original GitHub issue

Hi, I’m working on a small aframe-react app where I need to update different geometry attributes via react state (like this: geometry={{ width: this.state.width }}).

When I’m using the geometry.primitive property everything works as expected, but when I’m using Primitives or the aframe-react-components module, all aframe-primitives are getting updated to geometry={{ primitive: 'box' }} when I update the react state.

This works as expected:

<Entity
  geometry={{ primitive: 'plane', width: this.state.width, height: '2' }}
  material={{color: 'blue' }}
  position='-4 -1.5 -8'
  onClick={this.changeWidth.bind(this)} />

This works onload, but when I update this.state.width the geometry.primitive of the <a-plane />-Element changes to ‘box’

<Entity
   primitive='a-plane'
   geometry={{ width: this.state.width, height: '2' }}
   material={{color: 'blue' }}
   position='-4 2.5 -8'
   onClick={this.changeWidth.bind(this)} />

I used the aframe-react-boilerplate to build a basic demo of the bug. The upper row uses aframe Primitives, the lower row uses the geometry.primitive property. Live Demo with v0.4.0 (Code)

onload after this.setState({})
before-state-update after-state-update

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ngokevincommented, Mar 27, 2017

Removed the props, and the test I had passes now.

1reaction
Stefiecommented, Mar 27, 2017

@robinnorth ah, the string [object Object] makes way more sense than the color property!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Updating Objects in State - React Docs
State can hold any kind of JavaScript value, including objects. But you shouldn't change objects that you hold in the React state directly....
Read more >
react-three-fiber: 3D rendering in the browser - LogRocket Blog
Renderers manage how a React tree turns into the underlying platform calls. ... A cube is a box shape so we will use...
Read more >
Handling Objects in React Component State | Ship Shape
Objects are a useful way to store data when you have a set of related values that you will be accessing or updating...
Read more >
Python state guide geometry - SideFX
If the node's output changes (for example, because it is driven by parameters on your asset), the contents of the Geometry object automatically...
Read more >
react-three-fiber - npm
These components react to state changes, are interactive out of the box and can ... When you know what a scene is, a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found