MCPcopy Create free account
hub / github.com/reactjs/react-rails / validateMethodOverride

Function validateMethodOverride

lib/assets/react-source/development/react.js:29621–29647  ·  view source on GitHub ↗
(isAlreadyDefined, name)

Source from the content-addressed store, hash-verified

29619 }
29620
29621 function validateMethodOverride(isAlreadyDefined, name) {
29622 var specPolicy = ReactClassInterface.hasOwnProperty(name)
29623 ? ReactClassInterface[name]
29624 : null;
29625
29626 // Disallow overriding of base class methods unless explicitly allowed.
29627 if (ReactClassMixin.hasOwnProperty(name)) {
29628 _invariant(
29629 specPolicy === 'OVERRIDE_BASE',
29630 'ReactClassInterface: You are attempting to override ' +
29631 '`%s` from your class specification. Ensure that your method names ' +
29632 'do not overlap with React methods.',
29633 name
29634 );
29635 }
29636
29637 // Disallow defining methods more than once unless explicitly allowed.
29638 if (isAlreadyDefined) {
29639 _invariant(
29640 specPolicy === 'DEFINE_MANY' || specPolicy === 'DEFINE_MANY_MERGED',
29641 'ReactClassInterface: You are attempting to define ' +
29642 '`%s` on your component more than once. This conflict may be due ' +
29643 'to a mixin.',
29644 name
29645 );
29646 }
29647 }
29648
29649 /**
29650 * Mixin helper which handles policy validation and reserved

Callers 1

mixSpecIntoComponentFunction · 0.70

Calls 1

_invariantFunction · 0.70

Tested by

no test coverage detected