@mearie/react 0.0.0 → 0.0.1-next.1
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/README.md +52 -0
- package/package.json +15 -11
- package/src/index.ts +0 -5
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# @mearie/react
|
|
2
|
+
|
|
3
|
+
React bindings for Mearie GraphQL client.
|
|
4
|
+
|
|
5
|
+
This package provides React hooks and components for using Mearie in React
|
|
6
|
+
applications.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install mearie @mearie/react
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { createClient, httpLink, cacheLink, graphql } from 'mearie';
|
|
18
|
+
import { ClientProvider, useQuery } from '@mearie/react';
|
|
19
|
+
|
|
20
|
+
const client = createClient({
|
|
21
|
+
links: [cacheLink(), httpLink({ url: 'https://api.example.com/graphql' })],
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
function App() {
|
|
25
|
+
return (
|
|
26
|
+
<ClientProvider client={client}>
|
|
27
|
+
<UserProfile userId="1" />
|
|
28
|
+
</ClientProvider>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function UserProfile({ userId }: { userId: string }) {
|
|
33
|
+
const { data, loading } = useQuery(
|
|
34
|
+
graphql(`
|
|
35
|
+
query GetUser($id: ID!) {
|
|
36
|
+
user(id: $id) {
|
|
37
|
+
id
|
|
38
|
+
name
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
`),
|
|
42
|
+
{ id: userId },
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
if (loading) return <div>Loading...</div>;
|
|
46
|
+
return <h1>{data.user.name}</h1>;
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Documentation
|
|
51
|
+
|
|
52
|
+
Full documentation is available at <https://mearie.dev/frameworks/react>.
|
package/package.json
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mearie/react",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"license": "MIT",
|
|
3
|
+
"version": "0.0.1-next.1",
|
|
4
|
+
"sideEffects": false,
|
|
6
5
|
"type": "module",
|
|
7
|
-
"main": "./
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
8
7
|
"files": [
|
|
9
|
-
"dist"
|
|
8
|
+
"dist",
|
|
9
|
+
"package.json",
|
|
10
|
+
"README.md"
|
|
10
11
|
],
|
|
11
12
|
"dependencies": {
|
|
12
|
-
"@mearie/core": "0.0.
|
|
13
|
+
"@mearie/core": "0.0.1-next.1"
|
|
13
14
|
},
|
|
14
15
|
"devDependencies": {
|
|
15
|
-
"@types/react": "^
|
|
16
|
-
"react": "^
|
|
17
|
-
"tsdown": "^0.15.
|
|
16
|
+
"@types/react": "^19.2.2",
|
|
17
|
+
"react": "^19.2.0",
|
|
18
|
+
"tsdown": "^0.15.8"
|
|
18
19
|
},
|
|
19
20
|
"peerDependencies": {
|
|
20
21
|
"react": "^18.0.0 || ^19.0.0"
|
|
@@ -30,6 +31,9 @@
|
|
|
30
31
|
"types": "./dist/index.d.ts",
|
|
31
32
|
"import": "./dist/index.js",
|
|
32
33
|
"require": "./dist/index.cjs"
|
|
33
|
-
}
|
|
34
|
-
|
|
34
|
+
},
|
|
35
|
+
"./package.json": "./package.json"
|
|
36
|
+
},
|
|
37
|
+
"module": "./dist/index.js",
|
|
38
|
+
"types": "./dist/index.d.ts"
|
|
35
39
|
}
|
package/src/index.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { ClientProvider, useClient } from './client-provider.tsx';
|
|
2
|
-
export { useQuery, type UseQueryReturn } from './use-query.ts';
|
|
3
|
-
export { useSubscription, type UseSubscriptionReturn, type UseSubscriptionOptions } from './use-subscription.ts';
|
|
4
|
-
export { useMutation, type UseMutationResult, type UseMutationReturn } from './use-mutation.ts';
|
|
5
|
-
export { useFragment, type UseFragmentReturn } from './use-fragment.ts';
|