@esitorsunil/new-folder 1.0.1 → 1.0.2
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 +69 -0
- package/package.json +1 -1
package/README.md
CHANGED
@@ -0,0 +1,69 @@
|
|
1
|
+
# React Notifications with Redux Toolkit
|
2
|
+
|
3
|
+
This project demonstrates how to integrate a notification panel using Redux Toolkit and a custom package `@esitorsunil/new-folder`.
|
4
|
+
|
5
|
+
## Setup
|
6
|
+
|
7
|
+
### 1. Install dependencies
|
8
|
+
|
9
|
+
```bash
|
10
|
+
npm install
|
11
|
+
Make sure to have your custom package installed:
|
12
|
+
|
13
|
+
bash
|
14
|
+
|
15
|
+
npm install @esitorsunil/new-folder
|
16
|
+
|
17
|
+
|
18
|
+
2. Store Configuration (store/appStore.js)
|
19
|
+
Configure your Redux store to include the notifications reducer from the custom package:
|
20
|
+
|
21
|
+
|
22
|
+
import { configureStore } from '@reduxjs/toolkit';
|
23
|
+
import { notificationsReducer } from '@esitorsunil/new-folder';
|
24
|
+
|
25
|
+
export const store = configureStore({
|
26
|
+
reducer: {
|
27
|
+
notifications: notificationsReducer,
|
28
|
+
},
|
29
|
+
});
|
30
|
+
|
31
|
+
|
32
|
+
3. Usage in React App (App.jsx)
|
33
|
+
Wrap your app with Redux Provider and import the NotificationsPanel and pushNotification action from the package:
|
34
|
+
|
35
|
+
|
36
|
+
import React from 'react';
|
37
|
+
import { Provider, useDispatch } from 'react-redux';
|
38
|
+
import { store } from './store/appStore';
|
39
|
+
import { NotificationsPanel, pushNotification } from '@esitorsunil/new-folder';
|
40
|
+
|
41
|
+
function SomeComponent() {
|
42
|
+
const dispatch = useDispatch();
|
43
|
+
|
44
|
+
const handleAddNotification = () => {
|
45
|
+
dispatch(pushNotification({
|
46
|
+
id: Date.now(),
|
47
|
+
type: 'success',
|
48
|
+
message: 'Hello from SomeComponent!',
|
49
|
+
}));
|
50
|
+
};
|
51
|
+
|
52
|
+
return (
|
53
|
+
<div>
|
54
|
+
<button onClick={handleAddNotification}>Show Notification</button>
|
55
|
+
</div>
|
56
|
+
);
|
57
|
+
}
|
58
|
+
|
59
|
+
export default function App() {
|
60
|
+
return (
|
61
|
+
<Provider store={store}>
|
62
|
+
<div>
|
63
|
+
<h1>My React App</h1>
|
64
|
+
<SomeComponent />
|
65
|
+
<NotificationsPanel />
|
66
|
+
</div>
|
67
|
+
</Provider>
|
68
|
+
);
|
69
|
+
}
|