<@UKW3LEYN4> I use react quite abit, I might be ab...
# javascript
z
@Soren Valle I use react quite abit, I might be able to help
s
Thanks. I'm struggling to get a react-redux store to work. Redux is throwing an error saying: " The previous state received by the reducer has unexpected type of "Object". Expected argument to be an object with the following keys: "properties"" The passed state is an array because the "properties" key is an Array<Property>. It seems as though some how Redux is expecting the entire state object, but is only getting the scoped state. Based on what I've been reading it's supposed to get the scoped state. I'm not able to determine why it would be expecting the entire state object.
If I had to guess as to where I have it wrong it would be in App.kt 26-36 since that part is not very clear between the Wrapper github read me, the redux docs, and the "tutorial" project.
So it turns out it was just a warning, and I had another error and I thought the two were related. For some reason Kotlin's js is sending back an "Object" and not a "plainObject". Not sure why Redux cares enough to give a red warning, but still works. ¯\_(ツ)_/¯ Certainly messes with newbies.
z
Soren, have you looked at the newer react useReducer api? Combined with the react context API, it can remove a lot of the need for redux.
Also, you might want to use interfaces combined with the json function when passing stuff between kotlin and javascript. The json function will construct a plain javascript object and the interface will help with type safety. I've found this to be a solution to a lot of problems when working with plain javascript APIs. Kotlin adds a lot of stuff to objects if you aren't careful.
s
I haven't tried them no, thank you for pointing them out. If I understand the utilization that would enable a more modular approach to the store. Thank you for the advice, being new to Kotlin little things like that are useful.