@idds/react 1.5.14 → 1.5.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -669,21 +669,19 @@ function Accordion(props) {
669
669
  const [itemIndex, setItemIndex] = useState(-1);
670
670
  const defaultOpenRef = useRef(defaultOpen);
671
671
  defaultOpenRef.current = defaultOpen;
672
+ const { registerItem, unregisterItem } = accordionGroup || {};
672
673
  useEffect(() => {
673
- if (accordionGroup) {
674
- const index = accordionGroup.registerItem(
675
- itemIdRef.current,
676
- defaultOpenRef.current
677
- );
674
+ if (registerItem) {
675
+ const index = registerItem(itemIdRef.current, defaultOpenRef.current);
678
676
  setItemIndex(index);
679
677
  }
680
678
  return () => {
681
- if (accordionGroup) {
682
- accordionGroup.unregisterItem(itemIdRef.current);
679
+ if (unregisterItem) {
680
+ unregisterItem(itemIdRef.current);
683
681
  setItemIndex(-1);
684
682
  }
685
683
  };
686
- }, [accordionGroup]);
684
+ }, [registerItem, unregisterItem]);
687
685
  const isInGroup = accordionGroup !== null;
688
686
  const isControlled = open !== void 0 || isInGroup;
689
687
  const isOpen = useMemo(() => {