CharlesStover / reactn

React, but with built-in global state management.
https://www.npmjs.com/package/reactn
MIT License
1.89k stars 85 forks source link

Destructuring objects not call #104

Closed shipcake closed 5 years ago

shipcake commented 5 years ago

I call react render (nextJS) eveything will fine. but one thing react can pass props to another component but get undefinded because I use Destructuring objects

render() { ... const {name,categories,description,price,property_type,coverimg} = this.global.data } ... console.log('from global: '+categories) console.log('from this global'+this.global.data.categories)

my return from global: undefined from this global5caf13bd4fe5aa019326ff0e <<< value is ok

This problem will show only I click to another page (nextJS cache data and apollo graphql cache too)

how to fix I writing the code is shortest is posible javascript it can.

NextJS React Apollo graphl

quisido commented 5 years ago

ReactN should have no impact on object destructuring. Are you sure that this.global.data is a data structure that supports destructuring? If it's not a vanilla JavaScript Object, it may not support it.

What do you get if you console.log(this.global.data)?

quisido commented 5 years ago

Closing this due to age. If you need further assistance, feel free to continue the discussion.