|
function createTransitionTimeoutPropValidator(transitionType) { |
function createTransitionTimeoutPropValidator(transitionType) {
var timeoutPropName = 'transition' + transitionType + 'Timeout';
var enabledPropName = 'transition' + transitionType;
return function(props) {
// If the transition is enabled
if (props[enabledPropName]) {
// If no timeout duration is provided
if (!props[timeoutPropName]) {
return new Error(
timeoutPropName + ' wasn\'t supplied to ReactCSSTransitionGroup: ' +
'this can cause unreliable animations and won\'t be supported in ' +
'a future version of React. See ' +
'https://fb.me/react-animation-transition-group-timeout for more ' +
'information.'
);
// If the duration isn't a number
} else if (typeof props[timeoutPropName] !== 'number') {
return new Error(timeoutPropName + ' must be a number (in milliseconds)');
}
}
};
}
Returning an error saying that the value was not supplied because the value supplied was 0.
It checks if the type was not a number in the else if but it's too late to catch that then because the if (!0) already succeded.
Something like this would be better:
function createTransitionTimeoutPropValidator(transitionType) {
var timeoutPropName = 'transition' + transitionType + 'Timeout';
var enabledPropName = 'transition' + transitionType;
return function(props) {
// If the transition is enabled
if (props[enabledPropName]) {
// If no timeout duration is provided
if (props[timeoutPropName] === undefined) {
return new Error(
timeoutPropName + ' wasn\'t supplied to ReactCSSTransitionGroup: ' +
'this can cause unreliable animations and won\'t be supported in ' +
'a future version of React. See ' +
'https://fb.me/react-animation-transition-group-timeout for more ' +
'information.'
);
} else if (typeof props[timeoutPropName] !== 'number') {
return new Error(timeoutPropName + ' must be a number (in milliseconds)');
}
}
};
}
react/src/addons/transitions/ReactCSSTransitionGroup.js
Line 22 in a87c855
Returning an error saying that the value was not supplied because the value supplied was
0.It checks if the type was not a number in the
else ifbut it's too late to catch that then because theif (!0)already succeded.Something like this would be better: