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

Change default behavior when mapDataToProps property is missing #14

Open
joepio opened this issue Aug 28, 2019 · 1 comment
Open

Change default behavior when mapDataToProps property is missing #14

joepio opened this issue Aug 28, 2019 · 1 comment

Comments

@joepio
Copy link
Contributor

joepio commented Aug 28, 2019

Currently, when a property is requested in mapDataToProps, but it is missing in the data, the result is that the component does not render and no error is emitted.

This can make debugging quite hard. When I can't see a view, there can be many possible causes:

  • Is my view registered correctly?
  • Does the type of the data matches my View?
  • Do I have any typo's in my View? (can happen in mapDataToProps, in the props of the component, in the proptypes / interface)
  • Is some prop missing in the data?

We might be able to rule out the last two by setting forceRender to true, and checking the logs:

MyComponent.linkOpts = {
  forceRender: true,
};

But I feel like this should not be necessary.

Possible default behaviors for when a mapDataToProps prop is missing in the data:

  • Render an Error component / throw error (in console)
  • Render another View (fallback / Thing view) (play maybe throw error)
@joepio joepio changed the title Change default behavior when mapDataToProps component misses Change default behavior when mapDataToProps property is missing Aug 28, 2019
@rescribet
Copy link
Owner

Logging a message notifying the user will be trivial to implement (and no change in behaviour 👍🏻).

Render an Error component

This would seam less OWA, so that would go against project goals. Though the current behaviour has limited usability, it does prevent unnecessary error views being rendered while still allowing the developer the option to manage missing data explicitly.

Render another View

It'd be neat to render a different view (It'd be akin to using a shape to qualify a view for selection), but that would be a very large overhaul (and make view selection significantly slower).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants