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

v6.5.x of core package requires to define an empty action on init the state of the tree. #1056

Closed
gquittet opened this issue May 29, 2024 · 1 comment · Fixed by #1054
Closed

Comments

@gquittet
Copy link
Contributor

gquittet commented May 29, 2024

Describe the bug
A clear and concise description of what the bug is.

With the v.6.4.x and below we can directly load the tree like this:

const config = CoreConfig;
const reducer = TreeStore(config)
const state = reducer({ tree: initTree })

CoreConfig is imported from "@react-awesome-query-builder/core"

initTree is just an empty tree build like this:

Utils.loadTree({
  id: Utils.uuid(),
  type: "group",
  children1: []
})

Now starting with v6.5.x, we have to define an empty action just to access the config because getLastConfig is undefined.

const config = CoreConfig;
const reducer = TreeStore(config)
// The type INIT_TREE can be whatever you want
const emptyAction = { type: "INIT_TREE", config }
const state = reducer({ tree: initTree }, emptyAction)

Without this modification, I get this error:

ERROR TypeError: action is undefined
    tree_default tree.js:886

image

And the I can't init the state of my tree.

To Reproduce

Install the v6.5.x and try the example above.

Expected behavior

It should load the state without this empty action.

If it is expected, we have to update the documentation.

@ukrbublik
Copy link
Owner

Thanks for the report.
It's a bug, will fix in next version

ukrbublik added a commit that referenced this issue May 31, 2024
@ukrbublik ukrbublik linked a pull request Jun 4, 2024 that will close this issue
ukrbublik added a commit that referenced this issue Jun 7, 2024
* Optimize render of MuiConjs

* show benchmark in example app

* reuse config extended from memo

* remove internal render optimizations

* use callback, memo

* antd Slider FC

* remove optimizeRenderWithInternals

* .

* fix test

* merge type config to field config @ extend

* fix issue #1056

* fix tests

* fix issue with negative spel #1055

* test spil minus

* chlog

* cache

* fix import of negative number as func arg

* memo

* fix tests

* fix
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

Successfully merging a pull request may close this issue.

2 participants