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

beautiful-react-redux/check should be configurable #4

Closed
pavelvlasov opened this issue Mar 16, 2018 · 4 comments
Closed

beautiful-react-redux/check should be configurable #4

pavelvlasov opened this issue Mar 16, 2018 · 4 comments

Comments

@pavelvlasov
Copy link

The initial suggestions will be to allow throw an error instead of console.error.

It might look like this:

import check from 'beautiful-react-redux/check';

check({throwError: true});

Any other thoughts @theKashey?

@theKashey
Copy link
Owner

The only question - who we are going to confugure - beautiful-react-redux, which could wrap shouldBePure with itown logic, or memoize-state, which generating errors.
There is also a problem with verbosity in memoize-state after theKashey/memoize-state#5

There is also one more point to configure - "the safe" memoization mode (https://github.com/theKashey/memoize-state/blob/master/src/index.js#L240) used here. It will also check that 2 "same" mapStateToProps calls will use the same keys to generate result, which may fail if you have deep reselect cascade.

Ie, look like configuration should be just passed down to memoizeState, and there is 3 points to set

  • log or throw in purityCheck
  • use safe mode or not.
  • detect spreads or not.

2 last are enabled by default, but might be better disabled.

@theKashey
Copy link
Owner

import setConfig from 'beautiful-react-redux/check'
setConfig({ onNotPure: (...errormsg) => { throw new Error(errormsg.join(''));

Not documented feature yet, not sure about naming. But you could try it.

@pavelvlasov
Copy link
Author

Looks good!
I would rename it to onError and pass error object in, e.g.

setConfig({onError: (err) => throw err});

I don't think you can do much with whatever array is passed in.

But huge thanks anyway 👍

@theKashey
Copy link
Owner

And now I have understand how to make it better....

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

No branches or pull requests

2 participants