-
Notifications
You must be signed in to change notification settings - Fork 1k
Accordion - Replace useId #7345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -19,6 +19,16 @@ const customTheme = { | |||
}; | |||
|
|||
describe('Accordion', () => { | |||
beforeEach(() => { | |||
jest.spyOn(Date, 'now').mockImplementation(() => 12345678); | |||
jest.spyOn(global.Math, 'random').mockReturnValue(0.123456789); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add comments about how you chose the values here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment in latest commit
// Ideally we should use `useId` from react but this is only available | ||
// in React 18 and we want to keep compatibility with React 17 and 16. | ||
function getUID() { | ||
const timestamp = Date.now().toString(36); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we do:
Date.now() + Math.random()
instead of just appending Math.random?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed in latest commit
What does this PR do?
Replaces useId in AccordionPanel because useId is only available in React 18 and we need to support react 16 and 17 as well.
This PR is targeted to merge into the react-compatibility branh so we can do a patch release from that branch
Where should the reviewer start?
What testing has been done on this PR?
How should this be manually tested?
Do Jest tests follow these best practices?
screen
is used for querying.asFragment()
is used for snapshot testing.Any background context you want to provide?
What are the relevant issues?
Screenshots (if appropriate)
Do the grommet docs need to be updated?
no
Should this PR be mentioned in the release notes?
yes
Is this change backwards compatible or is it a breaking change?
backwards compatible