Giter Club home page Giter Club logo

Comments (15)

stubailo avatar stubailo commented on May 21, 2024 2

@jbaxleyiii perhaps we should use lodash.assign?

from react-apollo.

arealmaas avatar arealmaas commented on May 21, 2024 1

@jbaxleyiii Yes sure, thanks! Yes i am! When using the connect function it fails. Tries to deep copy state by using Object.assign which i believe doesn't work well with immutablejs. I also got some errors of wrong usage of Object.assign:

One of the sources for assign has an enumerable key on the prototype chain. This is an edge case that we do not support. This error is a performance optimization and not spec compliant.

I get this error by just using connect from apollo.

Dunno what needs to be done tho. Check if the state is immutable before assigning? not sure

from react-apollo.

arealmaas avatar arealmaas commented on May 21, 2024

changed from

var storeState = this.store.getState();
this.state = Object.assign({}, storeState)

to

var storeState = this.store.getState();
this.state = storeState.toJS()

And it started working again. Seems like an issue with Object.assign and react native, prooobably not related to this lib :))

from react-apollo.

jbaxleyiii avatar jbaxleyiii commented on May 21, 2024

@stubailo sounds good too me. I can change that out and open a PR this evening for it, unless you or someone else wants to get to it sooner?

Also, welcome back!

from react-apollo.

stubailo avatar stubailo commented on May 21, 2024

Hey good to be back! So relaxing :) I can try, but I have a lot of meetings so it might be much later today.

from react-apollo.

jbaxleyiii avatar jbaxleyiii commented on May 21, 2024

haha same here 👍

from react-apollo.

arealmaas avatar arealmaas commented on May 21, 2024

Does assign even work with immutable Map?

from react-apollo.

arealmaas avatar arealmaas commented on May 21, 2024

nvm.. The issue seems to be the use of immutable reducers.. Seems like react-apollo doesn't treat immutable data very well :)

from react-apollo.

jbaxleyiii avatar jbaxleyiii commented on May 21, 2024

@AlmaasAre can you show me your usage? I'd love to improve this lib to support immutable data! Are you using immutable.js?

from react-apollo.

jbaxleyiii avatar jbaxleyiii commented on May 21, 2024

@AlmaasAre yep! I need to add in a check for immutablejs 👍

from react-apollo.

aweary avatar aweary commented on May 21, 2024

Does it make more sense to provide a way for the user to map their storeState to connect's local state? If you just add a check for immutable.js you'll still have the same problem when users are using other immutable libraries.

Instead maybe connect can accept a function like getStateFromStoreState that passes in storeState and lets the user parse and return a plain object representing their state.

from react-apollo.

stubailo avatar stubailo commented on May 21, 2024

Apollo Client now supports React Native as of 0.3.27! Going to close this issue because most of the conversation is about Immutable.js and not React Native.

from react-apollo.

davidyaha avatar davidyaha commented on May 21, 2024

I think that with the 0.5.25 version of apollo-client that uses object spread and polyfills with Object.assign, this bug came back..
In my implementation this happens on refetch.
Also I think this issue belongs in apollo-client rather than here.

from react-apollo.

helfer avatar helfer commented on May 21, 2024

@davidyaha is this still the case for you with 0.7.1? If so, please open an issue on apollo-client! ❤️

from react-apollo.

davidyaha avatar davidyaha commented on May 21, 2024

Not sure.. I will update next week probably and if it reappears I'll open a new issue.

from react-apollo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.