Skip to content

Commit

Permalink
Improve useIsMountedState and useIsMounted examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaNarie committed Apr 4, 2023
1 parent a5b7da0 commit eae00dc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/hooks/useIsMounted/useIsMounted.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ function DemoComponent() {
Use in `useEffect` cleanup, for some very specific scenarios.

```tsx
import { useEffect } from 'react';
function DemoComponent() {
function DemoComponent({ someChangingValue }) {
const isMounted = useIsMounted();

useEffect(() => {
Expand Down
4 changes: 3 additions & 1 deletion src/hooks/useIsMountedState/useIsMountedState.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ console.log(isMounted); // false
Trigger a re-render after the component is mounted to update the state.

```tsx
function DemoComponent() {
import {somethingSameAsServer, somethingCustomOnTheClient} from './somewhere.js';

function DemoComponent({ otherItems }) {
const isMounted = useIsMountedState();

// help with SSR, since `isMounted` is part of the deps,
Expand Down

0 comments on commit eae00dc

Please sign in to comment.