verifySubselectors.js 787 B

1234567891011121314151617
  1. import warning from '../utils/warning';
  2. function verify(selector, methodName, displayName) {
  3. if (!selector) {
  4. throw new Error("Unexpected value for " + methodName + " in " + displayName + ".");
  5. } else if (methodName === 'mapStateToProps' || methodName === 'mapDispatchToProps') {
  6. if (!Object.prototype.hasOwnProperty.call(selector, 'dependsOnOwnProps')) {
  7. warning("The selector for " + methodName + " of " + displayName + " did not specify a value for dependsOnOwnProps.");
  8. }
  9. }
  10. }
  11. export default function verifySubselectors(mapStateToProps, mapDispatchToProps, mergeProps, displayName) {
  12. verify(mapStateToProps, 'mapStateToProps', displayName);
  13. verify(mapDispatchToProps, 'mapDispatchToProps', displayName);
  14. verify(mergeProps, 'mergeProps', displayName);
  15. }