react-rock 3.1.4 → 3.1.6
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/package.json +1 -1
- package/readme.md +11 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-rock",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.6",
|
|
4
4
|
"author": "Naxrul Ahmed",
|
|
5
5
|
"description": "React-Rock is a modern, lightweight state management library designed to simplify handling global state in React applications. With a minimal API and powerful features like freezing data updates for optimized re-renders, React-Rock allows you to manage state more efficiently while ensuring your app remains fast and responsive.",
|
|
6
6
|
"main": "./index.js",
|
package/readme.md
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img width="120" src="https://raw.githubusercontent.com/devnax/react-rock/main/logo.png" alt="React Rock logo">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">React Rock</h1>
|
|
2
6
|
|
|
3
7
|
React-Rock is a lightweight package for managing global state in React applications. It simplifies handling data by providing a store with rows and metadata, while offering methods to perform CRUD operations and more. It enables easy integration with React components, making it an ideal solution for managing complex state in large applications.
|
|
4
8
|
|
|
@@ -79,7 +83,7 @@ Here’s a table with all available methods and their descriptions:
|
|
|
79
83
|
The `find` method allows you to search for rows in the store based on specific conditions:
|
|
80
84
|
|
|
81
85
|
```typescript
|
|
82
|
-
const foundUsers = users.find({ name:
|
|
86
|
+
const foundUsers = users.find({ name: 'John Doe' } });
|
|
83
87
|
console.log(foundUsers);
|
|
84
88
|
```
|
|
85
89
|
|
|
@@ -153,10 +157,10 @@ class UserList extends StoreComponent {
|
|
|
153
157
|
users.create({ name: 'Alice', age: 25 });
|
|
154
158
|
|
|
155
159
|
// Update a user
|
|
156
|
-
users.update({ age: 26 }, { name:
|
|
160
|
+
users.update({ age: 26 }, { name: 'Alice' } });
|
|
157
161
|
|
|
158
162
|
// Delete a user
|
|
159
|
-
users.delete({ name:
|
|
163
|
+
users.delete({ name: 'Alice' } });
|
|
160
164
|
```
|
|
161
165
|
|
|
162
166
|
## Examples with `find` and Query
|
|
@@ -167,7 +171,7 @@ const usersOver25 = users.find({ age: { gt: 25 } });
|
|
|
167
171
|
console.log(usersOver25);
|
|
168
172
|
|
|
169
173
|
// Find the first user with the name 'Alice'
|
|
170
|
-
const alice = users.findFirst({ name:
|
|
174
|
+
const alice = users.findFirst({ name: 'Alice' } });
|
|
171
175
|
console.log(alice);
|
|
172
176
|
```
|
|
173
177
|
|
|
@@ -180,7 +184,7 @@ import { StoreComponent } from 'react-rock';
|
|
|
180
184
|
|
|
181
185
|
class UserList extends StoreComponent {
|
|
182
186
|
render() {
|
|
183
|
-
const users =
|
|
187
|
+
const users = users.getAll();
|
|
184
188
|
return (
|
|
185
189
|
<div>
|
|
186
190
|
{users.map(user => <div key={user._id}>{user.name}</div>)}
|
|
@@ -191,7 +195,7 @@ class UserList extends StoreComponent {
|
|
|
191
195
|
|
|
192
196
|
class UserProfile extends StoreComponent {
|
|
193
197
|
render() {
|
|
194
|
-
const user =
|
|
198
|
+
const user = users.findFirst({ name: 'John Doe' });
|
|
195
199
|
return <div>{user ? user.name : 'User not found'}</div>;
|
|
196
200
|
}
|
|
197
201
|
}
|