@ptolemy2002/react-mount-effects 1.1.1 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +14 -1
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,4 +1,17 @@
1
- # React Library CRA Template
1
+ # React Mount Effects
2
+ React allows `useEffect(() => {callback()}, [])` to run the callback only on first mount, thus `useEffect(() => callback, [])` only runs on unmounting. However, eslint often complains about this. This library manually suppresses those warnings and exports the hooks for convenience sake.
3
+
4
+ The hooks are not exported as default, so you can import in one of the following ways:
5
+ ```
6
+ //ES6
7
+ import { useMountEffect, useUnmountEffect } from '@ptolemy2002/react-mount-effects';
8
+ //CommonJS
9
+ const { useMountEffect, useUnmountEffect } = require('@ptolemy2002/react-mount-effects');
10
+ ```
11
+
12
+ Both hooks take only one argument, the callback.
13
+
14
+ ## Meta
2
15
  This is a React Library Created by Ptolemy2002's [cra-template-react-library](https://www.npmjs.com/package/@ptolemy2002/cra-template-react-library) template in combination with [create-react-app](https://www.npmjs.com/package/create-react-app). It contains methods of building and publishing your library to npm.
3
16
  For now, the library makes use of React 18 and does not use TypeScript.
4
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptolemy2002/react-mount-effects",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "main": "index.js",
5
5
  "files": [
6
6
  "index.js"
@@ -24,7 +24,7 @@
24
24
  "url": "https://github.com/Ptolemy2002/react-mount-effects",
25
25
  "directory": "lib"
26
26
  },
27
- "description": "Example of a React library",
27
+ "description": "Dedicated effect functions for React component mount and unmount",
28
28
  "license": "ISC",
29
29
  "peerDependencies": {
30
30
  "@types/react": "^18.3.3",