Skip to content

Commit

Permalink
Merge pull request #1151 from silx-kit/warn-duplicate-interaction
Browse files Browse the repository at this point in the history
Warn when trying to register two interactions with the same ID
  • Loading branch information
axelboc authored Jul 1, 2022
2 parents 1cf0667 + 669bc64 commit c862e89
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/lib/src/interactions/InteractionsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ function InteractionsProvider(props: { children: ReactNode }) {

const registerInteraction = useCallback(
(id: string, value: InteractionEntry) => {
interactionMap.set(id, { id, ...value });
if (interactionMap.has(id)) {
console.warn(`An interaction with ID "${id}" is already registered.`); // eslint-disable-line no-console
} else {
interactionMap.set(id, { id, ...value });
}
},
[interactionMap]
);
Expand Down

0 comments on commit c862e89

Please sign in to comment.