Skip to content

bug: initialState function not working for deep object mutations #227

@bordagabor

Description

@bordagabor

Prerequisites

Stencil Store Version

2.0.4

Stencil Version

3.0.0

Current Behavior

According to the documentation, the initialState property can be a function that returns the actual initial state. This is useful for cases where we have deep objects that mutate, as the library is unable to track those changes otherwise. However, I have found that this feature does not seem to be working as expected.
Also, the typing is not correct - the exported state is treated as a function in case I pass function to the createStore

Expected Behavior

When using a function as the initialState, changes to deep objects should be reactive and properly tracked and updated by the library.

Steps to Reproduce

  1. Create store with the createStore function and pass a function which is return with the initialState according to the docs.
  2. Observe that changes to the deep object are not being tracked as expected.

Code Reproduction URL

https://codesandbox.io/p/sandbox/happy-kowalevski-vi29n6

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug: ValidatedThis PR or Issue is verified to be a bug within Stencil StoreHelp Wanted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions