Skip to content

Commit

Permalink
PR Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
BPScott committed Sep 5, 2019
1 parent 14fd04a commit 484472e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ Use [the changelog guidelines](https://git.io/polaris-changelog-guidelines) to f
### Code quality

- Migrated `ActionMenu.RollupAction`, `Autocomplete`, `Card`, `EmptySearchResult`, `Form`, `SkeletonPage` and `TopBar` to use hooks instead of withAppProvider ([#2065](https://github.com/Shopify/polaris-react/pull/2065))
- Added `useUniqueId` hook that can be used to get a unique id that remains consistent between rerenders and update components to use it where appropriate ([#2079](https://github.com/Shopify/polaris-react/pull/2079))
- Added `useUniqueId` hook that can be used to get a unique id that remains consistent between rerenders and updated components to use it where appropriate ([#2079](https://github.com/Shopify/polaris-react/pull/2079))

### Deprecations
8 changes: 4 additions & 4 deletions src/components/RadioButton/RadioButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ export function RadioButton({
onChange,
onFocus,
onBlur,
id: providedId,
name: providedName,
id: idProp,
name: nameProp,
value,
}: RadioButtonProps) {
const id = useUniqueId('RadioButton', providedId);
const name = providedName || id;
const id = useUniqueId('RadioButton', idProp);
const name = nameProp || id;

function handleChange({currentTarget}: React.ChangeEvent<HTMLInputElement>) {
onChange && onChange(currentTarget.checked, id);
Expand Down
3 changes: 1 addition & 2 deletions src/utilities/unique-id/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ export function useUniqueId(prefix = '', override?: string) {
// rerendering of a component
// The first time a component is rendered the ref will be empty.
// In that case fill it with the next available ID
// Only populating this on first render means we don't create a new Id on
// every render
// On subsequent renders we use the existing value instead of using a new id
const currentComponentIdRef = useRef<string | null>(null);

if (!currentComponentIdRef.current) {
Expand Down

0 comments on commit 484472e

Please sign in to comment.