Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elisherer/use-gravatar
React hook (memoized) for getting gravatar's url based on email address
https://github.com/elisherer/use-gravatar
Last synced: about 5 hours ago
JSON representation
React hook (memoized) for getting gravatar's url based on email address
- Host: GitHub
- URL: https://github.com/elisherer/use-gravatar
- Owner: elisherer
- License: mit
- Created: 2021-11-24T12:17:44.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2021-11-25T07:18:02.000Z (almost 3 years ago)
- Last Synced: 2024-10-29T00:56:57.805Z (17 days ago)
- Language: TypeScript
- Size: 17.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![npm version](https://badge.fury.io/js/use-gravatar.svg)](https://www.npmjs.com/package/use-gravatar)
# useGravatar
A React hook (memoized) for getting gravatar's url based on email address## Usage
```tsx
import { useGravatar } from 'use-gravatar';const Component = ({ email } : { email: string }) => {
const src = useGravatar(email, 48);
return (
)
}
```## API
```ts
/**
* Simple function to generate a gravatar avatar image url based on email and size
* @param email {string} Email to use for Gravatar
* @param [size] {number} Size of avatar (in pixels)
*/
export declare const toGravatar: (email: string, size?: number) => string;
/**
* Hook to generate and memoize a gravatar avatar image url based on email and size
* @param email {string} Email to use for Gravatar
* @param [size] {number} Size of avatar (in pixels)
*/
export declare const useGravatar: (email: string, size?: number) => string;
/**
* Hook to create and memoize (based on email) a gravatar avatar image url generation function based on size
* This should be used when same email Gravatar is used in the same component in different sizes
* @param email {string} Email to use for Gravatar
*/
export declare const useGravatarFactory: (email: string) => (size: number) => string;
/**
* MD5 function, converts input to MD5 hex string
* @param input {string} Input string
*/
export declare const md5hex: (input: string) => string;
```
## LICENSEMIT