Skip to content

Commit

Permalink
docs: update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
shenjunru committed Jun 8, 2022
1 parent a1a2e1d commit 087f688
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ ReactDOM.render((

- Wrap your component with `keepLive()`
```JavaScript
import { keepAlive } from 'react-fiber-keep-alive';
const NewComponent = keepAlive(YourComponent, (props) => {
// props: the income props for `<YourComponent>`
Expand All @@ -82,8 +84,19 @@ ReactDOM.render((
});
```

- Hook: `useIgnoreKeepAlive()` returns a cache cleaner function.
```JavaScript
import { useIgnoreKeepAlive } from 'react-fiber-keep-alive';

const ignoreCache = useIgnoreKeepAlive();

ignoreCache(`unique-key`);
```

- If the `render()` of class component has side effects.
```JavaScript
import { markClassComponentHasSideEffectRender } from 'react-fiber-keep-alive';

markClassComponentHasSideEffectRender(ClassComponent);

// Example:
Expand All @@ -98,6 +111,8 @@ ReactDOM.render((

- If no need to trigger the effect hook while remounting.
```JavaScript
import { markEffectHookIsOnetime } from 'react-fiber-keep-alive';
markEffectHookIsOnetime(effectHook);
// Example:
Expand Down

0 comments on commit 087f688

Please sign in to comment.