### WhatsappShareButton Example
Source: https://github.com/nygardk/react-share/blob/master/README.md
Example usage of the WhatsappShareButton component.
```jsx
import { WhatsappShareButton, WhatsappIcon } from "react-share";
;
```
--------------------------------
### Icon Example
Source: https://github.com/nygardk/react-share/blob/master/README.md
Example of using an icon component like XIcon.
```jsx
import { XIcon } from "react-share";
;
```
--------------------------------
### FacebookShareCount Example
Source: https://github.com/nygardk/react-share/blob/master/README.md
Basic example of using the FacebookShareCount component.
```jsx
```
--------------------------------
### Install react-share
Source: https://github.com/nygardk/react-share/blob/master/README.md
Command to install the react-share package using npm.
```shell
npm install react-share
```
--------------------------------
### WhatsappShareButton Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example of using the WhatsappShareButton to share content via WhatsApp.
```typescript
import { WhatsappShareButton, WhatsappIcon } from 'react-share';
```
--------------------------------
### FacebookShareButton Basic Example
Source: https://github.com/nygardk/react-share/blob/master/README.md
Basic example of using FacebookShareButton with FacebookIcon.
```jsx
import { FacebookShareButton, FacebookIcon } from "react-share";
;
```
--------------------------------
### WeiboShareButton Example
Source: https://github.com/nygardk/react-share/blob/master/README.md
Example usage of the WeiboShareButton component with optional props.
```jsx
import { WeiboShareButton, WeiboIcon } from "react-share";
;
```
--------------------------------
### WorkplaceShareButton Example
Source: https://github.com/nygardk/react-share/blob/master/README.md
Example usage of the WorkplaceShareButton component with optional props.
```jsx
import { WorkplaceShareButton, WorkplaceIcon } from "react-share";
;
```
--------------------------------
### TypeScript Strict Types Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/configuration.md
Example demonstrating type-safe custom components with strict TypeScript.
```typescript
import { FacebookShareButton } from 'react-share';
import type { ShareButtonProps } from 'react-share'; // If exported
// Type-safe custom component
const CustomShareButton: React.FC<{
url: string;
title?: string;
}> = ({ url, title }) => (
{title}
);
```
--------------------------------
### WeiboShareButton Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example of using the WeiboShareButton to share content to Weibo.
```typescript
import { WeiboShareButton, WeiboIcon } from 'react-share';
```
--------------------------------
### XShareButton Example
Source: https://github.com/nygardk/react-share/blob/master/README.md
Example of using XShareButton with custom title and htmlTitle.
```jsx
import { XShareButton, XIcon } from "react-share";
;
```
--------------------------------
### TypeScript Generic Props Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/configuration.md
Example showing how to use generics for platform-specific props in TypeScript.
```typescript
import { type ShareButtonProps } from 'react-share';
type CustomProps = ShareButtonProps<{
title?: string;
}>;
```
--------------------------------
### ViberShareButton Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example of using the ViberShareButton to share content via Viber.
```typescript
import { ViberShareButton, ViberIcon } from 'react-share';
```
--------------------------------
### Basic Icon Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/IconBase.md
Example of how to use the IconBase component with a basic SVG path.
```jsx
import IconBase from 'react-share/icons/IconBase';
```
--------------------------------
### PocketShareButton Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example usage of the PocketShareButton component for saving articles to Pocket.
```typescript
import { PocketShareButton, PocketIcon } from 'react-share';
```
--------------------------------
### Custom Background Styling Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/IconBase.md
Example of applying custom styles to the background shape using 'bgStyle'.
```jsx
```
--------------------------------
### LiveJournal Share Button Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example usage of the LiveJournal Share Button with its props.
```typescript
import { LivejournalShareButton, LivejournalIcon } from 'react-share';
```
--------------------------------
### Hatena Share Button Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example usage of the Hatena Share Button with its props.
```typescript
import { HatenaShareButton, HatenaIcon } from 'react-share';
```
--------------------------------
### Line Share Button Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example usage of the Line Share Button with its props.
```typescript
import { LineShareButton, LineIcon } from 'react-share';
```
--------------------------------
### BlueskyShareButton Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example usage of the BlueskyShareButton component with BlueskyIcon.
```typescript
import { BlueskyShareButton, BlueskyIcon } from 'react-share';
```
--------------------------------
### Icon with Custom Styling
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example demonstrating custom styling for an X icon.
```typescript
import { XIcon } from 'react-share';
```
--------------------------------
### Icon Sizing
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/configuration.md
Examples of configuring icon size using pixels, CSS strings, or the default value.
```typescript
// Pixel size
// String size (CSS)
// Default size
// 64px
```
--------------------------------
### Pinterest Share Button
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/configuration.md
Example of using the PinterestShareButton component with required media and optional description and pinId.
```typescript
```
--------------------------------
### OKShareButton Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example usage of the OKShareButton component for sharing content on Odnoklassniki (OK.ru).
```typescript
import { OKShareButton, OKIcon } from 'react-share';
```
--------------------------------
### XIcon Usage
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of how to import and use the XIcon component.
```typescript
import { XIcon } from 'react-share';
```
--------------------------------
### FacebookShareCount Custom Rendering Example
Source: https://github.com/nygardk/react-share/blob/master/README.md
Example of custom rendering for FacebookShareCount using a render prop.
```jsx
{(shareCount) => {shareCount}}
```
--------------------------------
### Gab Share Button Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example usage of the Gab Share Button with its props.
```typescript
import { GabShareButton, GabIcon } from 'react-share';
```
--------------------------------
### VKShareButton Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example of using the VKShareButton to share content to VK (VKontakte).
```typescript
import { VKShareButton, VKIcon } from 'react-share';
```
--------------------------------
### FacebookShareButton Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example usage of the FacebookShareButton component with FacebookIcon.
```typescript
import { FacebookShareButton, FacebookIcon } from 'react-share';
```
--------------------------------
### FacebookMessengerShareButton Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example usage of the FacebookMessengerShareButton component with FacebookMessengerIcon.
```typescript
import { FacebookMessengerShareButton, FacebookMessengerIcon } from 'react-share';
```
--------------------------------
### EmailShareButton Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example usage of the EmailShareButton component with EmailIcon.
```typescript
import { EmailShareButton, EmailIcon } from 'react-share';
```
--------------------------------
### PocketIcon Usage
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of how to import and use the PocketIcon component.
```typescript
import { PocketIcon } from 'react-share';
```
--------------------------------
### Creating Custom Icons
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/IconBase.md
Instructions and example for creating a new custom icon component.
```jsx
import IconBase, { type IconProps } from 'react-share/icons/IconBase';
export function MyCustomIcon(props: IconProps) {
return (
{/* Your SVG path elements */}
);
}
```
--------------------------------
### OKIcon Usage
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of using the OKIcon component.
```typescript
import { OKIcon } from 'react-share';
```
--------------------------------
### Pinterest with Media
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/OVERVIEW.md
Example of sharing an image on Pinterest with a URL, media URL, and description.
```typescript
```
--------------------------------
### PinterestShareButton Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example usage of the PinterestShareButton component for pinning images on Pinterest.
```typescript
import { PinterestShareButton, PinterestIcon } from 'react-share';
```
--------------------------------
### TumblrShareButton Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example of how to use the TumblrShareButton component to share content to Tumblr.
```typescript
import { TumblrShareButton, TumblrIcon } from 'react-share';
```
--------------------------------
### Instapaper Share Button Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example usage of the Instapaper Share Button with its props.
```typescript
import { InstapaperShareButton, InstapaperIcon } from 'react-share';
```
--------------------------------
### LinkedIn Share Button Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example usage of the LinkedIn Share Button with its props.
```typescript
import { LinkedinShareButton, LinkedinIcon } from 'react-share';
```
--------------------------------
### Window Positioning
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/configuration.md
Examples of how to center the share popup relative to the browser window or the entire screen.
```typescript
// Center relative to browser window (default)
// Center relative to entire screen
```
--------------------------------
### RedditShareButton Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example usage of the RedditShareButton component for sharing content on Reddit.
```typescript
import { RedditShareButton, RedditIcon } from 'react-share';
```
--------------------------------
### Icon Colors
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/configuration.md
Example of overriding icon fill color and background styles.
```typescript
```
--------------------------------
### Icons v2
Source: https://github.com/nygardk/react-share/blob/master/docs/migrate-v1-to-v2.md
Importing FacebookIcon directly in v2.
```javascript
import { FacebookIcon } from 'react-share';
```
--------------------------------
### XShareButton Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example of how to use the XShareButton component to share content to X (formerly Twitter).
```typescript
import { XShareButton, XIcon } from 'react-share';
```
--------------------------------
### LinkedIn Share Button
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/configuration.md
Example of using the LinkedinShareButton component with optional title, summary, and source.
```typescript
```
--------------------------------
### VKIcon Usage
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of how to import and use the VKIcon component.
```typescript
import { VKIcon } from 'react-share';
```
--------------------------------
### TelegramShareButton Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example usage of the TelegramShareButton component for sharing via Telegram.
```typescript
import { TelegramShareButton, TelegramIcon } from 'react-share';
```
--------------------------------
### Mail.ru Share Button Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example usage of the Mail.ru Share Button with its props.
```typescript
import { MailruShareButton, MailruIcon } from 'react-share';
```
--------------------------------
### WhatsappIcon Usage
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of how to import and use the WhatsappIcon component.
```typescript
import { WhatsappIcon } from 'react-share';
```
--------------------------------
### Facebook Messenger Share Button Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example usage of the Facebook Messenger Share Button with its props.
```typescript
import {
FacebookMessengerShareButton,
FacebookMessengerIcon
} from 'react-share';
```
--------------------------------
### ViberIcon Usage
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of how to import and use the ViberIcon component.
```typescript
import { ViberIcon } from 'react-share';
```
--------------------------------
### WorkplaceIcon Usage
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of how to import and use the WorkplaceIcon component.
```typescript
import { WorkplaceIcon } from 'react-share';
```
--------------------------------
### PinterestIcon Usage
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of using the PinterestIcon component.
```typescript
import { PinterestIcon } from 'react-share';
```
--------------------------------
### Icons v1
Source: https://github.com/nygardk/react-share/blob/master/docs/migrate-v1-to-v2.md
Generating FacebookIcon using generateShareIcon in v1.
```javascript
import { generateShareIcon } from 'react-share';
const FacebookIcon = generateShareIcon('facebook');
```
--------------------------------
### CSS Reset and Styling Hooks
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/configuration.md
Example of CSS class hooks provided by react-share for styling.
```typescript
// All share buttons
.react-share__ShareButton { }
// When disabled
.react-share__ShareButton--disabled { }
// Also added when disabled
.disabled { }
// Share count containers
.react-share__ShareCount { }
```
--------------------------------
### WeiboIcon Usage
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of how to import and use the WeiboIcon component.
```typescript
import { WeiboIcon } from 'react-share';
```
--------------------------------
### FacebookIcon Usage
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of using the FacebookIcon component.
```typescript
import { FacebookIcon } from 'react-share';
```
--------------------------------
### Twitter/X Share Button
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/configuration.md
Example of using the XShareButton component with optional via, hashtags, and related.
```typescript
```
--------------------------------
### createShareCount HOC Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Utilities.md
Example of creating a custom share count component using the createShareCount higher-order component.
```typescript
import createShareCount from 'react-share/hocs/createShareCount';
// Create a custom share count component
const CustomShareCount = createShareCount((url, callback) => {
fetch(`/api/share-count?url=${encodeURIComponent(url)}`)
.then(res => res.json())
.then(data => callback(data.count))
.catch(() => callback(undefined));
});
// Use the component
```
--------------------------------
### Facebook Share Button
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/configuration.md
Example of using the FacebookShareButton component with optional hashtag.
```typescript
```
--------------------------------
### HatenaIcon Usage
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of using the HatenaIcon component.
```typescript
import { HatenaIcon } from 'react-share';
```
--------------------------------
### VK Share Button
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/configuration.md
Example of using the VKShareButton component with optional image, noParse, and noVkLinks.
```typescript
```
--------------------------------
### Custom Rendering of Share Count
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/configuration.md
Example of custom rendering for share counts using a render function.
```typescript
{(count) => {count}}
```
--------------------------------
### TelegramIcon Usage
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of how to import and use the TelegramIcon component.
```typescript
import { TelegramIcon } from 'react-share';
```
--------------------------------
### Email Share Button
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/configuration.md
Example of using the EmailShareButton component with optional subject, body, and separator.
```typescript
```
--------------------------------
### LineIcon Usage
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of using the LineIcon component.
```typescript
import { LineIcon } from 'react-share';
```
--------------------------------
### LivejournalIcon Usage
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of using the LivejournalIcon component.
```typescript
import { LivejournalIcon } from 'react-share';
```
--------------------------------
### BlueskyIcon Usage
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of using the BlueskyIcon component.
```typescript
import { BlueskyIcon } from 'react-share';
```
--------------------------------
### GabIcon Usage
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of using the GabIcon component.
```typescript
import { GabIcon } from 'react-share';
```
--------------------------------
### InstapaperIcon Usage
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of using the InstapaperIcon component.
```typescript
import { InstapaperIcon } from 'react-share';
```
--------------------------------
### RedditIcon Usage
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of how to import and use the RedditIcon component.
```typescript
import { RedditIcon } from 'react-share';
```
--------------------------------
### Share counts v1
Source: https://github.com/nygardk/react-share/blob/master/docs/migrate-v1-to-v2.md
Importing FacebookShareCount and GooglePlusShareCount from ShareCounts in v1.
```javascript
import { ShareCounts } from 'react-share';
const {
FacebookShareCount,
GooglePlusShareCount,
} = ShareCounts;
```
--------------------------------
### WorkplaceShareButton Usage
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example of how to use the WorkplaceShareButton component with basic props.
```typescript
import { WorkplaceShareButton, WorkplaceIcon } from 'react-share';
```
--------------------------------
### EmailIcon Usage
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of using the EmailIcon component.
```typescript
import { EmailIcon } from 'react-share';
```
--------------------------------
### TumblrIcon Usage
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of how to import and use the TumblrIcon component.
```typescript
import { TumblrIcon } from 'react-share';
```
--------------------------------
### Share buttons v1
Source: https://github.com/nygardk/react-share/blob/master/docs/migrate-v1-to-v2.md
Importing FacebookShareButton and TwitterShareButton from ShareButtons in v1.
```javascript
import { ShareButtons } from 'react-share';
const {
FacebookShareButton,
TwitterShareButton,
} = ShareButtons;
```
--------------------------------
### Share counts v2
Source: https://github.com/nygardk/react-share/blob/master/docs/migrate-v1-to-v2.md
Importing FacebookShareCount and GooglePlusShareCount directly in v2.
```javascript
import {
FacebookShareCount,
GooglePlusShareCount,
} from 'react-share';
```
--------------------------------
### Tumblr Share Button
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/configuration.md
Example of using the TumblrShareButton component with optional title, caption, tags, and posttype.
```typescript
```
--------------------------------
### ThreadsShareButton Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example usage of the ThreadsShareButton component for sharing on Threads.
```typescript
import { ThreadsShareButton, ThreadsIcon } from 'react-share';
```
--------------------------------
### Accessibility for Decorative Icons
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of making icons decorative for screen readers.
```typescript
```
--------------------------------
### Icon with Share Button
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of integrating an icon with a share button component.
```typescript
import { FacebookShareButton, FacebookIcon } from 'react-share';
```
--------------------------------
### Manual Share Dialog Control
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/configuration.md
Example of preventing the auto-opening of the dialog and handling the share manually.
```typescript
{
// Handle share manually
window.open(shareUrl, 'share', 'width=550,height=400');
}}
>
```
--------------------------------
### Share buttons v2
Source: https://github.com/nygardk/react-share/blob/master/docs/migrate-v1-to-v2.md
Importing FacebookShareButton and TwitterShareButton directly in v2.
```javascript
import {
FacebookShareButton,
TwitterShareButton,
} from 'react-share';
```
--------------------------------
### Main Entry Point
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/OVERVIEW.md
Shows the main imports available from the react-share library, including share buttons, icons, and deprecated share count components.
```typescript
import {
// Share Buttons (25+)
FacebookShareButton,
XShareButton,
LinkedinShareButton,
// ... other buttons
// Icons (25+)
FacebookIcon,
XIcon,
LinkedinIcon,
// ... other icons
// Share Counts (Deprecated)
FacebookShareCount,
RedditShareCount,
// ... other counts
} from 'react-share';
```
--------------------------------
### Custom Styling for Icons
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of overriding background color, icon fill color, and other styles.
```typescript
import { FacebookIcon } from 'react-share';
```
--------------------------------
### Pinterest Link Generator
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Utilities.md
Example of the internal pinterestLink function used to generate Pinterest share URLs.
```typescript
function pinterestLink(url: string, { media, description, pinId }: PinterestShareProps): string {
if (pinId) {
return `https://pinterest.com/pin/${pinId}/repin/x/`;
}
return 'https://pinterest.com/pin/create/button/' + objectToGetParams({
url,
media,
description,
});
}
```
--------------------------------
### Default Size
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/IconBase.md
Example showing IconBase rendering with its default size when the size prop is omitted.
```typescript
```
--------------------------------
### Facebook Messenger Share Button
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/configuration.md
Example of using the FacebookMessengerShareButton component with required appId and optional redirectUri and to.
```typescript
```
--------------------------------
### CSS Integration Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/IconBase.md
Demonstrates integrating IconBase with CSS classes and inline styles for custom styling.
```typescript
```
```css
.social-icon {
cursor: pointer;
transition: transform 0.2s;
}
.social-icon:hover {
transform: scale(1.1);
}
```
--------------------------------
### TwitterShareButton (Deprecated) Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareButtons.md
Example of using the deprecated TwitterShareButton, noting its alias to XShareButton.
```typescript
import { TwitterShareButton, TwitterIcon } from 'react-share';
// Equivalent to XShareButton
```
--------------------------------
### Handle Share Actions
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/OVERVIEW.md
Example demonstrating how to handle share actions, including pre-click hooks and callbacks for when the share dialog is closed.
```typescript
{
// Track before sharing
await fetch('/api/track-share', { method: 'POST' });
}}
onClick={(event, shareUrl) => {
console.log('Shared URL:', shareUrl);
}}
onShareWindowClose={() => {
console.log('Share dialog closed');
}}
>
```
--------------------------------
### File Structure Overview
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/INDEX.md
This snippet shows the directory structure of the react-share library, indicating the location of various documentation files.
```bash
/output/
├── INDEX.md ← You are here
├── README.md # Navigation and structure guide
├── OVERVIEW.md # Library overview and quick start
├── types.md # TypeScript type definitions
├── configuration.md # Configuration and customization
├── api-reference/
│ ├── ShareButtons.md # 25+ button components
│ ├── Icons.md # 25 icon components
│ ├── ShareCounts.md # 7 deprecated count components
│ ├── IconBase.md # Internal icon base component
│ └── Utilities.md # Helper functions and hooks
└── [This file]
```
--------------------------------
### Rounded Rectangle Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/IconBase.md
Example of using IconBase with the 'borderRadius' prop for rounded corners.
```jsx
```
--------------------------------
### Circular Icon Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/IconBase.md
Example of using IconBase with the 'round' prop for a circular background.
```jsx
```
--------------------------------
### Custom Fill Color Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/IconBase.md
Example of overriding the default icon fill color using 'iconFillColor'.
```jsx
```
--------------------------------
### TumblrShareCount Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareCounts.md
Fetches and displays the share count from Tumblr. Includes an example with custom rendering.
```typescript
import { TumblrShareCount } from 'react-share';
// With custom rendering
{(count) => {count} reblogs}
```
--------------------------------
### RedditShareCount Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareCounts.md
Fetches and displays the share count from Reddit. Includes an example with custom rendering.
```typescript
import { RedditShareCount } from 'react-share';
// With custom rendering
{(count) => {count} upvotes}
```
--------------------------------
### TypeScript Import
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/OVERVIEW.md
Illustrates how to import components and types in a TypeScript project.
```typescript
import { FacebookShareButton } from 'react-share';
import type { ShareButtonProps } from 'react-share'; // If exported
```
--------------------------------
### useIsMounted Hook Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Utilities.md
Example of using the useIsMounted hook to prevent state updates after a component unmounts during asynchronous operations.
```typescript
import { useIsMounted } from 'react-share/hooks/useIsMounted';
function MyComponent() {
const isMounted = useIsMounted();
useEffect(() => {
fetchData().then(data => {
if (isMounted()) {
setData(data); // Safe - won't warn about unmounted component
}
});
}, [isMounted]);
return
{/* ... */}
;
}
```
--------------------------------
### VKShareCount Example
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/ShareCounts.md
Fetches and displays the share count from VK (VKontakte). Includes an example with custom rendering.
```typescript
import { VKShareCount } from 'react-share';
// With custom rendering
{(count) => {count} shares}
```
--------------------------------
### Async Operations - beforeOnClick Hook
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/configuration.md
Demonstrates using the `beforeOnClick` hook to run asynchronous operations before the share dialog opens.
```typescript
{
// Runs immediately on click
console.log('User clicked share');
}}
>
```
```typescript
{
// Dialog waits until this completes
await fetch('/api/track-share');
}}
>
```
--------------------------------
### MailruIcon Usage
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of using the MailruIcon component.
```typescript
import { MailruIcon } from 'react-share';
```
--------------------------------
### LivejournalShareButton
Source: https://github.com/nygardk/react-share/blob/master/README.md
Optional props: title, description.
```jsx
import { LivejournalShareButton, LivejournalIcon } from "react-share";
;
```
--------------------------------
### LinkedinIcon Usage
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of using the LinkedinIcon component.
```typescript
import { LinkedinIcon } from 'react-share';
```
--------------------------------
### File Organization
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/README.md
The directory structure of the react-share library.
```tree
output/
├── README.md # This file
├── OVERVIEW.md # Library overview and quick start
├── types.md # TypeScript types and interfaces
├── configuration.md # Configuration guide
├── api-reference/
│ ├── ShareButtons.md # All share button components
│ ├── Icons.md # All icon components
│ ├── ShareCounts.md # Deprecated share count components
│ ├── IconBase.md # Internal icon base component
│ └── Utilities.md # Helper functions and hooks
```
--------------------------------
### CSS Classes for styling
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/configuration.md
Share buttons apply specific CSS classes that can be used for styling.
```css
.react-share__ShareButton {
border-radius: 4px;
padding: 4px;
}
.react-share__ShareButton--disabled {
cursor: not-allowed;
}
```
--------------------------------
### FacebookMessengerIcon Usage
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/api-reference/Icons.md
Example of using the FacebookMessengerIcon component.
```typescript
import { FacebookMessengerIcon } from 'react-share';
```
--------------------------------
### Multiple Buttons
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/OVERVIEW.md
Illustrates how to render multiple share buttons for different platforms.
```typescript
import {
FacebookShareButton,
TwitterShareButton,
LinkedinShareButton,
FacebookIcon,
XIcon,
LinkedinIcon,
} from 'react-share';
function ShareButtons() {
const url = 'https://example.com';
return (
);
}
```
--------------------------------
### HatenaShareButton
Source: https://github.com/nygardk/react-share/blob/master/README.md
Optional prop: title.
```jsx
import { HatenaShareButton, HatenaIcon } from "react-share";
;
```
--------------------------------
### BlueskyShareButton
Source: https://github.com/nygardk/react-share/blob/master/README.md
Optional props: title, separator. Example usage with BlueskyIcon.
```jsx
import { BlueskyShareButton, BlueskyIcon } from "react-share";
;
```
--------------------------------
### Basic Usage
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/OVERVIEW.md
Demonstrates the basic usage of a share button component with its corresponding icon.
```typescript
import { FacebookShareButton, FacebookIcon } from 'react-share';
export function ShareWidget() {
const url = 'https://example.com';
return (
);
}
```
--------------------------------
### Tree-shaking Optimized Import
Source: https://github.com/nygardk/react-share/blob/master/_autodocs/OVERVIEW.md
Demonstrates the recommended way to import components for tree-shaking, importing only the necessary parts of the library.
```typescript
// ✓ Good - imports only needed components
import { FacebookShareButton, FacebookIcon } from 'react-share';
// Avoid - imports entire library
import * as Share from 'react-share';
```