Skip to content

Commit

Permalink
reduce size?
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Apr 6, 2020
1 parent 33a18f8 commit 5dd0780
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions packages/material-ui/src/utils/useId.js
Expand Up @@ -3,18 +3,15 @@ import * as React from 'react';
/**
* Private module reserved for @material-ui/x packages.
*/
export default function useId(idProp) {
const [defaultId, setDefaultId] = React.useState();
const id = idProp || defaultId;
export default function useId(idOverride) {
const [id, setId] = React.useState(idOverride);
React.useEffect(() => {
if (defaultId) {
return;
if (idOverride == null) {
// Fallback to this default id when possible.
// Use the random value for client-side rendering only.
// We can't use it server-side.
setId(`mui-${Math.round(Math.random() * 1e5)}`);
}

// Fallback to this default id when possible.
// Use the random value for client-side rendering only.
// We can't use it server-side.
setDefaultId(`mui-${Math.round(Math.random() * 1e5)}`);
}, [defaultId]);
}, [idOverride]);
return id;
}

0 comments on commit 5dd0780

Please sign in to comment.