avkonst / hookstate

The simple but very powerful and incredibly fast state management for React that is based on hooks
https://hookstate.js.org
MIT License
1.66k stars 109 forks source link

having problem with getting rid of proxy #403

Open piotr-kozlowski-reps opened 1 year ago

piotr-kozlowski-reps commented 1 year ago

I have problem with getting into plain data object via state.get() method.

Here's a small getter to have value out of hookstate:

    getCyclicalActivityFormikDataForPUT() {
      return state.get({ noproxy: true, stealth: true })
        .cyclicalActivityFormikDataForPUT;
    },

I also tried:

    getCyclicalActivityFormikDataForPUT() {
      return state.cyclicalActivityFormikDataForPUT.get({
        noproxy: true,
        stealth: true,
      });
    }

but my output is still: ImmutableObject<ImmutableObject<.....someType>> and should be just: <.....someType>

What am I doing wrong? help please. I just need plain data object to copy into Formik as initial state.

avkonst commented 1 year ago

You are doing all right. You get the object but it's type is readonly, which is correct. You are not allowed to change this object. There is a discussion around if ImmutableObject is useful. As of today just to cast to as yourtype.

piotr-kozlowski-reps commented 1 year ago

ok, I messed up Proxiness and Immutability :) Simple casting did the trick, thank you.