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

some state variable not reset properly when reused #22

Open
oliverbienert opened this issue Feb 16, 2017 · 5 comments
Open

some state variable not reset properly when reused #22

oliverbienert opened this issue Feb 16, 2017 · 5 comments

Comments

@oliverbienert
Copy link

Hello,

I might have found a bug. I have the following redux tree:

      {
        id: 'landcover_wood',
        name: 'Landcover Wood',
        active: false,
        visible: true,
        style: {
          fill: 'rgba(237, 239, 245, 1)',
          outline: 'rgba(181, 223, 245, 1)'
        },
        origstyle: {
          fill: 'rgba(237, 239, 245, 1)',
          outline: 'rgba(181, 223, 245, 1)'
        }
      },
      {
        id: 'water',
        name: 'Water',
        active: true,
        visible: true,
        style: {
          fill: 'rgba(154, 172, 216, 1)'
        },
        origstyle: {
          fill: 'rgba(225, 231, 245, 1)'
        }
      },

After persisting, the second node also has 'outline' sub elements, but with a value of zero:

      {
        id: 'water',
        name: 'Water',
        active: true,
        visible: true,
        style: {
          fill: 'rgba(154, 172, 216, 1)',
          outline: null
        },
        origstyle: {
          fill: 'rgba(225, 231, 245, 1)',
          outline: null
        }
      },

Can you help out?

Cheers Oliver

@rt2zz
Copy link
Owner

rt2zz commented Feb 20, 2017

@oliverbienert that is odd, is outline: null part of initial state?

@oliverbienert
Copy link
Author

No, it's not. Initial state is this:

state = Map({
  hidemap: false,
  layers: List()
}

Then I have an action called INIT_LAYERS that fills the layers list with a list of Map objects. Data comes from a mapbox-gl-js instance wrapped in a react component. Some layers have a fill and an outline property (polygon layer such as landcover_wood in my example) some have just a fill colour (such as water or streets).
By the way, I also send this part of the redux tree to a REST API to store it in a database. For this to work I convert with toJS() and back with fromJS(), which works.
So I suspect the error somewhere in your code but I might be wrong.

@rt2zz
Copy link
Owner

rt2zz commented Feb 22, 2017

we use https://github.com/glenjamin/transit-immutable-js to serialize the immutable objects. Perhaps the error lies in there?

I am not sure off the top of my head. Perhaps others will chime in with similar issues.

@oliverbienert
Copy link
Author

When I look at my state with the help of ReduxDevTools, the key in question seems to not exist, however when I debug my code, an immutable has("outline") returns true and in the dev tools I indeed see the key but with a value of undefined.
So I'm afraid the error is in my code or I need a better understanding of how immutable works. Or it's the way redux works.
So for now, sorry for the noise.

@rt2zz
Copy link
Owner

rt2zz commented Apr 2, 2017

All good. That sounds strange, and from the outside I have no idea what is going on. If you find resolution please post back here

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