Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// debugger;
if (!isNaN(newValue) && refName != 'meridiem') {
let newDegree;
if (refName == 'clockHandSecond') {
newDegree = Number(newValue) * SECOND_DEGREE_NUMBER;
}
if (refName == 'clockHandMinute') {
newDegree = Number(newValue) * MINUTE_DEGREE_NUMBER;
}
if (refName == 'clockHandHour') {
if (Number(newValue) == 0) {
newValue = 12;
}
newDegree = Number(newValue) * HOUR_DEGREE_NUMBER;
}
elObj = update(elObj, {
value: { $set: newValue },
degree: { $set: newDegree },
startAngle: { $set: newDegree },
angle: { $set: newDegree }
});
this.setState({ [refName]: elObj, slectionRange });
}
if (key == 'ArrowUp' || key == 'ArrowDown') {
if (refName == 'meridiem') {
let meridiem = 'AM';
if (elObj == 'AM') {
meridiem = 'PM';
}
elObj = meridiem;
this.setState({ [refName]: elObj, slectionRange });
const mergeTracks = ({state, tracks}) => {
let existingTracks = state.tracks;
const updateCommand = {};
// don't want to overwrite tracks if already have more info
for (let track of tracks) {
if (existingTracks[track.id]) {
track = {...existingTracks[track.id], ...track};
}
updateCommand[track.id] = {$set: track};
}
return {
...state,
tracks: update(state.tracks, updateCommand)
};
};
setTimeout(() => {
var {markers} = this.state;
markers = update(markers, {
$push: [
{
position: {
lat: 25.99,
lng: 122.9,
},
defaultAnimation: 2,
key: Date.now(),// Add a key property for: http://fb.me/react-warning-keys
},
],
});
this.setState({ markers });
}, 2000);
}
rootSwap(function (rootVal) {
var nextRootVal;
if (path.length > 0) {
nextRootVal = persistentUpdate(
rootVal,
path.concat(operation).reduceRight(
unDeref,
leafUpdate(getRefAtPath(rootVal, path))
)
);
} else if (path.length === 0) {
nextRootVal = leafUpdate(rootVal);
}
// would be better to do this valEq check on just the leaf
return valEq(rootVal, nextRootVal)
? rootVal // preserve === if same value
: nextRootVal;
});
}
export function updateIn (rootVal, paths, f, ...args) {
let ff = (v) => f.apply(null, [v].concat(args));
var newRootVal;
if (paths.length > 0) {
const command = rootAt(paths, {$apply: ff});
newRootVal = persistentUpdate(rootVal, command);
}
else if (paths.length === 0) {
newRootVal = ff(rootVal);
}
// would be better to do this valEq check on just the leaf
return isEqual(rootVal, newRootVal)
? rootVal // preserve === if same value
: newRootVal;
}
_handle_map_click (event) {
var {markers} = this.state;
markers = update(markers, {
$push: [
{
position: event.latLng,
defaultAnimation: 2,
key: Date.now(),// Add a key property for: http://fb.me/react-warning-keys
},
],
});
this.setState({ markers });
}
addItem() {
let newState = reactUpdate(this.state, {
invoice: {
items: {
$push: [this.newItem]
}
},
openDialogStandardActions: {$set: false}
});
this.setState(newState);
this.newItem = {};
}
handleOperationPath(e) {
const newState = update(this.state, { newOperation: {path: {$set: e.target.value}} })
this.setState(newState)
}
_showScrollY () {
this.setState({
scrollYStyles: update(this.state.scrollYStyles, {
display: { $set: 'block' },
height: { $set: this._getScrollYHeight() }
})
})
}
function updateProductInPhases(phases, phaseId, productId, updateProduct, shouldReplace) {
const phaseIdx = _.findIndex(phases, { id: phaseId })
const productIdx = _.findIndex(phases[phaseIdx].products, { id: productId })
const updatedProduct = shouldReplace ? updateProduct : update(
phases[phaseIdx].products[productIdx],
updateProduct
)
const updatedPhase = update(phases[phaseIdx], {
products: { $splice: [[productIdx, 1, updatedProduct]] }
})
return update(phases, { $splice : [[phaseIdx, 1, updatedPhase]] })
}