Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 });
}
export function unshift (as, bs) {
return persistentUpdate(as, {$unshift: bs});
}
handleMarkerRightclick(index, event) {
/*
* All you modify is data, and the view is driven by data.
* This is so called data-driven-development. (And yes, it's now in
* web front end and even with google maps API.)
*/
let { markers } = this.state;
markers = update(markers, {
$splice: [
[index, 1],
],
});
this.setState({ markers });
}
export function merge (a, b) {
return persistentUpdate(a, {$merge: b});
}
handleMapZoomChanged() {
this.setState(update(this.state, {
geoStateBy: {
0: {
$merge: {
zoom: this.refs.map.getZoom(),
},
},
1: {
$merge: {
opacity: 0.2 + (this.refs.map.getZoom() / 14),
},
},
},
}));
}
export function push (as, bs) {
return persistentUpdate(as, {$push: bs});
}
handleMarkerClick() {
this.setState(update(this.state, {
geoStateBy: {
0: {
$merge: {
zoom: 1 + this.refs.map.getZoom(),
},
},
},
}));
}