Skip to content

Commit

Permalink
Merge pull request #25 from faceless-ui/chore/nanoid
Browse files Browse the repository at this point in the history
feat: implements useId hook
  • Loading branch information
jacobsfletch authored Oct 5, 2022
2 parents 6258f64 + c3aeb1c commit 509f265
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
10 changes: 3 additions & 7 deletions src/Collapsible/Provider/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, useId } from 'react';
import CollapsibleContext, { ICollapsibleContext } from './context';
import useCollapsibleGroup from '../../CollapsibleGroup/useCollapsibleGroup';
import { makeID } from '../../makeID';

export const collapsibleBaseClass = 'collapsible';

Expand Down Expand Up @@ -37,11 +36,8 @@ const Collapsible: React.FC<CollapsibleProps> = (props) => {
const [prevGroupToggleCount, setPrevGroupToggleCount] = useState(0);

// NOTE: the 'aria-owns' and 'aria-labelledby' attributes rely on this matching IDs
const [id, setID] = useState(() => idFromProps || makeID(5));

useEffect(() => {
setID(idFromProps || makeID(5));
}, [idFromProps])
const uniqueID = useId();
const id = idFromProps || uniqueID;

useEffect(() => {
if (openFromProps !== undefined) {
Expand Down
14 changes: 0 additions & 14 deletions src/makeID.ts

This file was deleted.

0 comments on commit 509f265

Please sign in to comment.