Skip to content

Commit

Permalink
MMT-3907: Added a useEffect to properly update available collections …
Browse files Browse the repository at this point in the history
…when providerId changes.
  • Loading branch information
Christopher D. Gokey committed Sep 27, 2024
1 parent 5b96ace commit bed1349
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,17 @@ const CollectionSelector = ({ onChange, formData, providerId }) => {
}), {})

const [selectedItems, setSelectedItems] = useState({})
const [availableItems, setAvailableItems] = useState(availableCollections)
const [availableItems, setAvailableItems] = useState([])

useEffect(() => {
setAvailableItems(availableCollections)
}, [providerId])

useEffect(() => {
if (!isEmpty(formData)) {
setSelectedItems(formData)
} else {
setSelectedItems({})
}
}, [formData])

Expand Down

0 comments on commit bed1349

Please sign in to comment.