| 1 |
/** SSR-safe ID generation component using render props. |
| 2 |
* For function components, prefer the useSSRSafeId hook instead. |
| 3 |
* |
| 4 |
* Example of how to use this component |
| 5 |
* |
| 6 |
* const Component = ({id}: {id: string}) => ( |
| 7 |
* <GenerateId>{randomId => ( |
| 8 |
* <div id={id || randomId}> |
| 9 |
* div with random ID |
| 10 |
* </div> |
| 11 |
* )} |
| 12 |
* </GenerateId> |
| 13 |
* ); |
| 14 |
*/ |
| 15 |
import { useSSRSafeId } from '../useSSRSafeId'; |
| 16 |
const GenerateId = ({ prefix = 'pf-random-id-', children }) => { |
| 17 |
const id = useSSRSafeId(prefix); |
| 18 |
return children(id); |
| 19 |
}; |
| 20 |
GenerateId.displayName = 'GenerateId'; |
| 21 |
export { GenerateId }; |
| 22 |
//# sourceMappingURL=GenerateId.js.map |