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

Fix #385: Avoid dynamic requires. #387

Merged
merged 2 commits into from
Nov 11, 2016
Merged

Fix #385: Avoid dynamic requires. #387

merged 2 commits into from
Nov 11, 2016

Conversation

n1k0
Copy link
Collaborator

@n1k0 n1k0 commented Nov 10, 2016

Refs #385

@dulguun0225 could you please confirm this would solve your issue?

@olzraiti I'd love a review from you on this.

@olzraiti
Copy link
Contributor

Looks all good to me!

@n1k0
Copy link
Collaborator Author

n1k0 commented Nov 10, 2016

In d2b3792 I avoid requiring on every call, which might save us a few nanoseconds.

Now waiting for @dulguun0225's feedback

@dulguun0225
Copy link

Yes, it would.

@glasserc glasserc mentioned this pull request Nov 10, 2016
@n1k0 n1k0 merged commit 1ff1549 into master Nov 11, 2016
n1k0 added a commit that referenced this pull request Nov 25, 2016
* Update dependencies to their latest versions. (#386)
* Fix #385: Avoid dynamic requires. (#387)
* Fix #365: Tab stop for Add button + (#392)
* Add a single field form example in the playground (#390)
* Allow using field names containing a dot character (#397)
* Updated eslint config.
* Improve checkbox and radio button styles (#403)
* Add missing proptype for disabled (#416)
* Temporary fix for #349 and facebook/react#7630 radio widget bug (#423)
@n1k0 n1k0 deleted the 385-no-dyn-require branch November 25, 2016 13:44
@n1k0
Copy link
Collaborator Author

n1k0 commented Nov 25, 2016

Released along v0.41.2.

@DanialK
Copy link

DanialK commented Dec 5, 2016

Hey guys,
I have just tried v0.41.2 and noticed that the object SchemaField.defaultProps.registry, is undefined. Basically as you can see in the logs, the first couple of times the getDefaultRegistry gets called it's returning undefined which is being set to the SchemaField.defaultProps.registry when doing


SchemaField.defaultProps = {
  registry: getDefaultRegistry()
};

image

image

Just to give you some context to my issue, i'm using a customised version of Kinto/formbuilder and here is where the problem occurred.

I currently have no idea why this is happening but would appreciate if you guys had any idea!
Cheers

@DanialK
Copy link

DanialK commented Dec 29, 2016

Hi @n1k0 ,

The issue above is not fixed yet and is due to cyclical imports because fields and widgets in defaultRegistry all call the getDefaultRegistry

SchemaField.defaultProps = {
  uiSchema: {},
  errorSchema: {},
  idSchema: {},
  registry: getDefaultRegistry(),  <-------
  disabled: false,
  readonly: false,
  autofocus: false,
};

// SchemaField.js
const defaultRegistry = {
  fields: require("./components/fields").default,
  widgets: require("./components/widgets").default,
  definitions: {},
  formContext: {}
};

export function getDefaultRegistry() {
  return defaultRegistry;
}

// utils.js
but then the defaultRegistry is not even loaded at that point so it returns undefined.
defaultRegistry codes should be moved to a seperate file that can be imported without causing this cyclic dependency issue.

Thanks

@vinhlh vinhlh mentioned this pull request May 7, 2017
2 tasks
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 this pull request may close these issues.

4 participants