Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

#2740 make sure changes to active prop change internal state

Jason Kent9d4a612c009c
diff --git a/web/js/components/util/switch.js b/web/js/components/util/switch.js
index f5144ff9b..e3e2c1b70 100644
--- a/web/js/components/util/switch.js
+++ b/web/js/components/util/switch.js
@@ -1,4 +1,4 @@
-import React, { useState } from 'react';
+import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import { Tooltip } from 'reactstrap';
@@ -20,6 +20,10 @@ const Switch = (props) => {
const activeColor = color || '007BFF';
const style = isActive ? { backgroundColor: `#${activeColor}` } : {};
+ useEffect(() => {
+ toggleActive(active);
+ }, [active]);
+
return (
<div className="react-switch">
<div className="react-switch-case switch-col">