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

The examples aren't self-contained #4

Open
leroydev opened this issue Mar 20, 2024 · 1 comment
Open

The examples aren't self-contained #4

leroydev opened this issue Mar 20, 2024 · 1 comment

Comments

@leroydev
Copy link
Contributor

leroydev commented Mar 20, 2024

I tried copying over the code from the antd Form List, added the necessary dependencies and ran into this issue:

config.tsx:62 Uncaught Error: Widget 'form-list' not defined. Did you define it?
    at Object.getWidgetDef (config.tsx:62:15)
    at NiceForm.tsx:65:26
    at Array.map (<anonymous>)
    at NiceForm (NiceForm.tsx:24:25)
    at renderWithHooks (react-dom.development.js:16305:18)
    at mountIndeterminateComponent (react-dom.development.js:20074:13)
    at beginWork (react-dom.development.js:21587:16)
    at HTMLUnknownElement.callCallback2 (react-dom.development.js:4164:14)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:16)
    at invokeGuardedCallback (react-dom.development.js:4277:31)

By copying this over from packages/examples-antd/src/main.tsx into the example code, it does work:

import { config as niceFormConfig } from '@ebay/nice-form-react';
import antdAdapter from '@ebay/nice-form-react/adapters/antdAdapter';

niceFormConfig.addAdapter(antdAdapter);

Because antdAdapter defines the form-list widget.
This is most likely the same for the formik form-list, but might happen in even more files.

To make it easier for developers to play around with nice-form-react, it'd be better if the example code is self-contained.

@leroydev
Copy link
Contributor Author

leroydev commented Mar 20, 2024

I'll see if I can come up with a solution for this.

Due to all examples being imported non lazily from App.tsx, it would seem like example B that is missing the adapter works after example A has been opened, due to the import of example A already having added the adapter.
That way it isn't easy to spot where the adapter needs to be added and where it is unnecessary.
I'll try and refactor it so App.tsx lazily imports the examples.

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.

1 participant