Skip to content

useValueEditor is missing the schema parameter #5

@hrz6976

Description

@hrz6976

Hi, thank you for creating this project! I got an error when using this with react-querybuild 8.3.1:

TypeError: Cannot destructure property 'classNames' of 't0' as it is undefined.
    at useValueEditor (http://localhost:4000/node_modules/.vite/deps/react-querybuilder.js?v=159b6c2f:5715:23)
    at ShadcnUiValueEditor (http://localhost:4000/src/components/querybuilder/value-editor.tsx:53:47)
    at react-stack-bottom-frame (http://localhost:4000/node_modules/.vite/deps/react-dom_client.js?v=159b6c2f:16192:20)
    at renderWithHooks (http://localhost:4000/node_modules/.vite/deps/react-dom_client.js?v=159b6c2f:4306:24)
    at updateFunctionComponent (http://localhost:4000/node_modules/.vite/deps/react-dom_client.js?v=159b6c2f:5972:21)
    at beginWork (http://localhost:4000/node_modules/.vite/deps/react-dom_client.js?v=159b6c2f:7048:20)
    at runWithFiberInDEV (http://localhost:4000/node_modules/.vite/deps/react-dom_client.js?v=159b6c2f:726:18)
    at performUnitOfWork (http://localhost:4000/node_modules/.vite/deps/react-dom_client.js?v=159b6c2f:10831:98)
    at workLoopSync (http://localhost:4000/node_modules/.vite/deps/react-dom_client.js?v=159b6c2f:10692:43)
    at renderRootSync (http://localhost:4000/node_modules/.vite/deps/react-dom_client.js?v=159b6c2f:10675:13)

The error comes from:

const { valueAsArray, multiValueHandler } = useValueEditor({
handleOnChange,
inputType,
operator,
value,
type,
listsAsArrays,
parseNumbers,
values,
});

The fix is simple:

  const { valueAsArray, multiValueHandler } = useValueEditor({
    handleOnChange,
    inputType,
    operator,
    value,
    type,
    listsAsArrays,
    parseNumbers,
    values,
+    schema: allProps.schema
  });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions