@quantajs/react 2.0.0-beta.1 → 2.0.0-beta.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.
- package/dist/index.cjs +7 -15
- package/dist/index.d.ts +16 -8
- package/dist/index.js +326 -603
- package/package.json +8 -4
- package/readme.md +140 -133
package/package.json
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"url": "https://github.com/quanta-js/quanta/issues"
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://quantajs.com",
|
|
25
|
-
"version": "2.0.0-beta.
|
|
25
|
+
"version": "2.0.0-beta.3",
|
|
26
26
|
"type": "module",
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"main": "./dist/index.js",
|
|
@@ -43,11 +43,15 @@
|
|
|
43
43
|
"react": ">=16.8.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@quantajs/core": "2.0.0-beta.
|
|
46
|
+
"@quantajs/core": "2.0.0-beta.3"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@types/react": "^
|
|
50
|
-
"react": "^
|
|
49
|
+
"@types/react": "^19.1.9",
|
|
50
|
+
"react": "^19.1.1"
|
|
51
|
+
},
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public",
|
|
54
|
+
"registry": "https://registry.npmjs.org/"
|
|
51
55
|
},
|
|
52
56
|
"scripts": {
|
|
53
57
|
"dev": "npm run format && npm run lint:fix && npm run build",
|
package/readme.md
CHANGED
|
@@ -1,133 +1,140 @@
|
|
|
1
|
-
# @quantajs/react
|
|
2
|
-
|
|
3
|
-

|
|
4
|
-
|
|
5
|
-
React integration for QuantaJS - A compact, scalable, and developer-friendly state management library for React applications.
|
|
6
|
-
|
|
7
|
-
## 🚀 Features
|
|
8
|
-
|
|
9
|
-
✅ **React Optimized** – Built specifically for React applications
|
|
10
|
-
✅ **Performance First** – Uses `useSyncExternalStore` for efficient updates
|
|
11
|
-
✅ **Type-Safe** – Full TypeScript support with proper inference
|
|
12
|
-
✅ **Flexible** – Multiple usage patterns (Provider, Direct, Selectors)
|
|
13
|
-
✅ **QuantaJS Core** – Direct access to reactive, computed, and watch
|
|
14
|
-
|
|
15
|
-
## 📦 Installation
|
|
16
|
-
|
|
17
|
-
```sh
|
|
18
|
-
npm install @quantajs/react @quantajs/core
|
|
19
|
-
# or
|
|
20
|
-
yarn add @quantajs/react @quantajs/core
|
|
21
|
-
# or
|
|
22
|
-
pnpm add @quantajs/react @quantajs/core
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## ⚡ Quick Start
|
|
26
|
-
|
|
27
|
-
### Basic Counter Example
|
|
28
|
-
|
|
29
|
-
```tsx
|
|
30
|
-
import React from 'react';
|
|
31
|
-
import { createStore, QuantaProvider, useStore } from '@quantajs/react';
|
|
32
|
-
|
|
33
|
-
// Create store
|
|
34
|
-
const counterStore = createStore('counter', {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
1
|
+
# @quantajs/react
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
React integration for QuantaJS - A compact, scalable, and developer-friendly state management library for React applications.
|
|
6
|
+
|
|
7
|
+
## 🚀 Features
|
|
8
|
+
|
|
9
|
+
✅ **React Optimized** – Built specifically for React applications
|
|
10
|
+
✅ **Performance First** – Uses `useSyncExternalStore` for efficient updates
|
|
11
|
+
✅ **Type-Safe** – Full TypeScript support with proper inference
|
|
12
|
+
✅ **Flexible** – Multiple usage patterns (Provider, Direct, Selectors)
|
|
13
|
+
✅ **QuantaJS Core** – Direct access to reactive, computed, and watch
|
|
14
|
+
|
|
15
|
+
## 📦 Installation
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm install @quantajs/react @quantajs/core
|
|
19
|
+
# or
|
|
20
|
+
yarn add @quantajs/react @quantajs/core
|
|
21
|
+
# or
|
|
22
|
+
pnpm add @quantajs/react @quantajs/core
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## ⚡ Quick Start
|
|
26
|
+
|
|
27
|
+
### Basic Counter Example
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import React from 'react';
|
|
31
|
+
import { createStore, QuantaProvider, useStore } from '@quantajs/react';
|
|
32
|
+
|
|
33
|
+
// Create store
|
|
34
|
+
const counterStore = createStore('counter', {
|
|
35
|
+
state: () => ({ count: 0 }),
|
|
36
|
+
getters: {
|
|
37
|
+
doubleCount: (state) => state.count * 2,
|
|
38
|
+
},
|
|
39
|
+
actions: {
|
|
40
|
+
increment() {
|
|
41
|
+
this.count++;
|
|
42
|
+
},
|
|
43
|
+
decrement() {
|
|
44
|
+
this.count--;
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Component
|
|
50
|
+
function Counter() {
|
|
51
|
+
const store = useStore();
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div>
|
|
55
|
+
<p>Count: {store.count}</p>
|
|
56
|
+
<p>Double: {store.doubleCount}</p>
|
|
57
|
+
<button onClick={() => store.increment()}>+</button>
|
|
58
|
+
<button onClick={() => store.decrement()}>-</button>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// App
|
|
64
|
+
function App() {
|
|
65
|
+
return (
|
|
66
|
+
<QuantaProvider store={counterStore}>
|
|
67
|
+
<Counter />
|
|
68
|
+
</QuantaProvider>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### With Selectors (Performance)
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
import { useQuantaStore } from '@quantajs/react';
|
|
77
|
+
|
|
78
|
+
function CounterDisplay() {
|
|
79
|
+
// Only re-render when count changes
|
|
80
|
+
const count = useQuantaStore(counterStore, (store) => store.count);
|
|
81
|
+
|
|
82
|
+
return <p>Count: {count}</p>;
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Component-Scoped Store
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import { useCreateStore } from '@quantajs/react';
|
|
90
|
+
|
|
91
|
+
function TodoComponent() {
|
|
92
|
+
const todoStore = useCreateStore(
|
|
93
|
+
'todos',
|
|
94
|
+
() => ({ todos: [] }),
|
|
95
|
+
undefined,
|
|
96
|
+
{
|
|
97
|
+
addTodo(text: string) {
|
|
98
|
+
this.todos.push({ id: Date.now(), text, done: false });
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<div>
|
|
105
|
+
<button onClick={() => todoStore.addTodo('New task')}>
|
|
106
|
+
Add Todo
|
|
107
|
+
</button>
|
|
108
|
+
<p>Todos: {todoStore.todos.length}</p>
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## 🔧 API
|
|
115
|
+
|
|
116
|
+
### Hooks
|
|
117
|
+
|
|
118
|
+
- `useQuantaStore(store, selector?)` - Subscribe to store with optional selector
|
|
119
|
+
- `useStore(selector?)` - Access store from QuantaProvider context
|
|
120
|
+
- `useCreateStore(name, state, getters?, actions?)` - Create component-scoped store
|
|
121
|
+
|
|
122
|
+
### Components
|
|
123
|
+
|
|
124
|
+
- `<QuantaProvider store={store}>` - Provide store to child components
|
|
125
|
+
|
|
126
|
+
### Core Features
|
|
127
|
+
|
|
128
|
+
- `createStore`, `reactive`, `computed`, `watch` - Re-exported from @quantajs/core
|
|
129
|
+
|
|
130
|
+
## 📜 License
|
|
131
|
+
|
|
132
|
+
This project is licensed under the MIT [License](https://github.com/quanta-js/quanta/blob/main/LICENSE) - see the LICENSE file for details.
|
|
133
|
+
|
|
134
|
+
## 💬 Contributing
|
|
135
|
+
|
|
136
|
+
We welcome contributions! Feel free to open issues, submit PRs, or suggest improvements.
|
|
137
|
+
|
|
138
|
+
## ⭐ Support
|
|
139
|
+
|
|
140
|
+
If you find this library useful, consider giving it a ⭐ star on [GitHub](https://github.com/quanta-js/quanta)!
|