ukrbublik/react-awesome-query-builder

Using renderField in version 6.4

Opened this issue · 3 comments

Describe the bug
Hello!

I migrated from react-awesome-query-builder version 5.4 to:
"@react-awesome-query-builder/mui": "^6.4.2"

In my code I'm customizing the config:


import { MuiConfig, BasicConfig } from '@react-awesome-query-builder/mui';

    const _customConfigWithTheme: BasicConfig = {
      ...MuiConfig,
      settings: {
        ...MuiConfig.settings,
        renderField: (props) => (
          <WithTheme theme={theme}>
            {
              MuiConfig.settings.renderField?.(props) // THIS LINE THROWS THE ERROR
            }
          </WithTheme>
        ),

That worked fine without any issues in version 5.4, but in version 6.4, I'm getting the error:

Uncaught TypeError: Cannot read properties of undefined (reading 'RCE')

The error is emerging from the line MuiConfig.settings.renderField?.(props), where I added the comment.

To Reproduce
Create a config with the above data

Expected behavior
Should not throw

Thanks a lot in advance

In renderField you should pass 2nd param: MuiConfig.ctx

If this works for you, please don't close the issue, I should mention this in readme

@omerfaran
Does this change fix your issue?

              MuiConfig.settings.renderField?.(props, MuiConfig.ctx) // THIS LINE THROWS THE ERROR

@omerfaran Does this change fix your issue?

              MuiConfig.settings.renderField?.(props, MuiConfig.ctx) // THIS LINE THROWS THE ERROR

Yes, thank you very much!
Keeping open