Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function logger(nextProps, nextState) {
if (enabled(groupName) || enabled(traceGroupName)) {
const
startTime = now(),
time = new Date(),
propsDiff = differ(this.props, nextProps),
stateDiff = differ(this.state, nextState),
groupTitle = `${groupName} @${time.getHours()}:${time.getMinutes()}:${time.getSeconds()}`
logGroup(groupTitle)
logPropsDiff(propsDiff)
logStateDiff(stateDiff)
console.debug(`→ logger took ${(now() - startTime).toFixed(3)}ms on instance ${this._reactInternalInstance._rootNodeID}`) // eslint-disable-line no-underscore-dangle
console.groupEnd(groupName)
}
}
function _getDiff(oldVal, newVal, actionType) {
const calcDiff = diff(oldVal, newVal);
if (!calcDiff || !calcDiff.length) {
return 'No changes';
}
return calcDiff.reduce((log, change) => {
let kind = _getChangeKind(change.kind);
let location;
// Special case to skip RECEIVE_CHART_OPTIONS* since it merges in new fields
if ('D' === change.kind && actions.RECEIVE_CHART_OPTIONS === actionType) {
return log;
}
// If not an array change
if ('A' !== change.kind) {
location = change.path.join('.');
const getDiffPaths = (before, after) => Array.from(new Set(diff(before, after).map(({ path }) => path.join('.'))))
if(this.widgetInstance.setOptions){
if(nextProps.options){
this.widgetInstance.setOptions(nextProps.options);
}
}
//try and determine if any of the nextProps have changed, and if so, update the widget
if(nextProps.methods){
if(deepDiff(nextProps.methods,this.props.methods)){
this.callKendoWidgetMethods(nextProps.methods);
}
}
if(nextProps.unbindEvents){
if(deepDiff(nextProps.unbindEvents,this.props.unbindEvents)){
this.unbindEventsToKendoWidget(nextProps.unbindEvents);
}
}
if(nextProps.triggerEvents){
if(deepDiff(nextProps.triggerEvents,this.props.triggerEvents)){
this.triggerKendoWidgetEvents(nextProps.triggerEvents);
}
}
},
componentWillReceiveProps: function(nextProps){
//always update the widget with nextProp changes if avaliable
if(nextProps.events){
this.bindEventsToKendoWidget(nextProps.events);
}
if(this.widgetInstance.setOptions){
if(nextProps.options){
this.widgetInstance.setOptions(nextProps.options);
}
}
//try and determine if any of the nextProps have changed, and if so, update the widget
if(nextProps.methods){
if(deepDiff(nextProps.methods,this.props.methods)){
this.callKendoWidgetMethods(nextProps.methods);
}
}
if(nextProps.unbindEvents){
if(deepDiff(nextProps.unbindEvents,this.props.unbindEvents)){
this.unbindEventsToKendoWidget(nextProps.unbindEvents);
}
}
if(nextProps.triggerEvents){
if(deepDiff(nextProps.triggerEvents,this.props.triggerEvents)){
this.triggerKendoWidgetEvents(nextProps.triggerEvents);
}
}
},
hasChanges() {
const {
defaultFilterState,
currentFilters,
} = this.props;
const differences = (clearTraits && clearTraits.length) ?
deepDiff(
pick(currentFilters, clearTraits),
pick(defaultFilterState, clearTraits)
) :
deepDiff(currentFilters, defaultFilterState);
return differences && differences.length;
}
componentWillReceiveProps: function(nextProps){
//always update the widget with nextProp changes if avaliable
if(nextProps.events){
this.bindEventsToKendoWidget(nextProps.events);
}
if(this.widgetInstance.setOptions){
if(nextProps.options){
this.widgetInstance.setOptions(nextProps.options);
}
}
//try and determine if any of the nextProps have changed, and if so, update the widget
if(nextProps.methods){
if(deepDiff(nextProps.methods,this.props.methods)){
this.callKendoWidgetMethods(nextProps.methods);
}
}
if(nextProps.unbindEvents){
if(deepDiff(nextProps.unbindEvents,this.props.unbindEvents)){
this.unbindEventsToKendoWidget(nextProps.unbindEvents);
}
}
if(nextProps.triggerEvents){
if(deepDiff(nextProps.triggerEvents,this.props.triggerEvents)){
this.triggerKendoWidgetEvents(nextProps.triggerEvents);
}
}
},
//try and determine if any of the nextProps have changed, and if so, update the widget
if(nextProps.methods){
if(deepDiff(nextProps.methods,this.props.methods)){
this.callKendoWidgetMethods(nextProps.methods);
}
}
if(nextProps.unbindEvents){
if(deepDiff(nextProps.unbindEvents,this.props.unbindEvents)){
this.unbindEventsToKendoWidget(nextProps.unbindEvents);
}
}
if(nextProps.triggerEvents){
if(deepDiff(nextProps.triggerEvents,this.props.triggerEvents)){
this.triggerKendoWidgetEvents(nextProps.triggerEvents);
}
}
},
//try and determine if any of the nextProps have changed, and if so, update the widget
if(nextProps.methods){
if(deepDiff(nextProps.methods,this.props.methods)){
this.callKendoWidgetMethods(nextProps.methods);
}
}
if(nextProps.unbindEvents){
if(deepDiff(nextProps.unbindEvents,this.props.unbindEvents)){
this.unbindEventsToKendoWidget(nextProps.unbindEvents);
}
}
if(nextProps.triggerEvents){
if(deepDiff(nextProps.triggerEvents,this.props.triggerEvents)){
this.triggerKendoWidgetEvents(nextProps.triggerEvents);
}
}
},
componentWillReceiveProps: function(nextProps){
//always update the widget with nextProp changes if avaliable
if(nextProps.events){
this.bindEventsToKendoWidget(nextProps.events);
}
if(this.widgetInstance.setOptions){
if(nextProps.options){
this.widgetInstance.setOptions(nextProps.options);
}
}
//try and determine if any of the nextProps have changed, and if so, update the widget
if(nextProps.methods){
if(deepDiff(nextProps.methods,this.props.methods)){
this.callKendoWidgetMethods(nextProps.methods);
}
}
if(nextProps.unbindEvents){
if(deepDiff(nextProps.unbindEvents,this.props.unbindEvents)){
this.unbindEventsToKendoWidget(nextProps.unbindEvents);
}
}
if(nextProps.triggerEvents){
if(deepDiff(nextProps.triggerEvents,this.props.triggerEvents)){
this.triggerKendoWidgetEvents(nextProps.triggerEvents);
}
}
},