@react-foundry/client-component-helpers 0.1.0
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.
- package/LICENSE +22 -0
- package/README.md +48 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -0
- package/dist/index.mjs +1 -0
- package/dist/is-mounted.d.ts +1 -0
- package/dist/is-mounted.js +14 -0
- package/dist/is-mounted.mjs +10 -0
- package/package.json +35 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2019-2025 Crown Copyright
|
|
4
|
+
Copyright (C) 2019-2026 Daniel A.C. Martin
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
7
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
8
|
+
the Software without restriction, including without limitation the rights to
|
|
9
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
10
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
11
|
+
so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
React Foundry - Client Component Helpers
|
|
2
|
+
========================================
|
|
3
|
+
|
|
4
|
+
Helper functions for writing client components.
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Using this package
|
|
8
|
+
------------------
|
|
9
|
+
|
|
10
|
+
First install the package into your project:
|
|
11
|
+
|
|
12
|
+
```shell
|
|
13
|
+
npm install -S @react-foundry/client-component-helpers
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Then use it in your code as follows:
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
import clientComponentHelpers from '@react-foundry/client-component-helpers';
|
|
20
|
+
|
|
21
|
+
// WRITEME
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
Working on this package
|
|
27
|
+
-----------------------
|
|
28
|
+
|
|
29
|
+
Before working on this package you must install its dependencies using
|
|
30
|
+
the following command:
|
|
31
|
+
|
|
32
|
+
```shell
|
|
33
|
+
pnpm install
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Building
|
|
38
|
+
|
|
39
|
+
```shell
|
|
40
|
+
npm run build
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### Clean-up
|
|
45
|
+
|
|
46
|
+
```shell
|
|
47
|
+
npm run clean
|
|
48
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './is-mounted';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./is-mounted"), exports);
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './is-mounted';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useIsMounted: () => boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useIsMounted = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
// Inspired by:
|
|
6
|
+
// - https://tech.willhaben.at/how-to-shoot-yourself-in-the-foot-in-react-401e7dbba720
|
|
7
|
+
// - https://www.joshwcomeau.com/react/the-perils-of-rehydration/
|
|
8
|
+
const useIsMounted = () => {
|
|
9
|
+
const [isMounted, setIsMounted] = (0, react_1.useState)(false);
|
|
10
|
+
const markAsMounted = () => setIsMounted(true);
|
|
11
|
+
(0, react_1.useEffect)(markAsMounted, []);
|
|
12
|
+
return isMounted;
|
|
13
|
+
};
|
|
14
|
+
exports.useIsMounted = useIsMounted;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
// Inspired by:
|
|
3
|
+
// - https://tech.willhaben.at/how-to-shoot-yourself-in-the-foot-in-react-401e7dbba720
|
|
4
|
+
// - https://www.joshwcomeau.com/react/the-perils-of-rehydration/
|
|
5
|
+
export const useIsMounted = () => {
|
|
6
|
+
const [isMounted, setIsMounted] = useState(false);
|
|
7
|
+
const markAsMounted = () => setIsMounted(true);
|
|
8
|
+
useEffect(markAsMounted, []);
|
|
9
|
+
return isMounted;
|
|
10
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-foundry/client-component-helpers",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Helper functions for writing client components.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.mjs",
|
|
10
|
+
"require": "./dist/index.js",
|
|
11
|
+
"default": "./dist/index.mjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"/dist"
|
|
16
|
+
],
|
|
17
|
+
"author": "Daniel A.C. Martin <npm@daniel-martin.co.uk> (http://daniel-martin.co.uk/)",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"react": "^19.2.3"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/react": "19.2.9",
|
|
24
|
+
"typescript": "5.9.3"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
28
|
+
"build": "npm run build:esm && npm run build:cjs",
|
|
29
|
+
"build:esm": "tsc -m es2022 && find dist -name '*.js' -exec sh -c 'mv \"$0\" \"${0%.js}.mjs\"' {} \\;",
|
|
30
|
+
"build:cjs": "tsc",
|
|
31
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo"
|
|
32
|
+
},
|
|
33
|
+
"module": "dist/index.mjs",
|
|
34
|
+
"typings": "dist/index.d.ts"
|
|
35
|
+
}
|