1.6.9 • Published 5 years ago
edkk-redux v1.6.9
by-jsonplaceholderredux
This package is jsonplaceholder redux package.
Installation
yarn add by-jsonplaceholderredux
npm i by-jsonplaceholderreduxUsage
// Store.js
import { createStore, applyMiddleware, compose, combineReducers } from "redux";
import thunk from "redux-thunk";
import { addReducerToList } from "by-jsonplaceholderredux/reducers";
const allReducer = addReducerToList();
const store = createStore(allReducer, {}, compose(applyMiddleware(thunk)));
export default store;// App.js
import React, { Component } from "react";
import { Provider, useSelector, useDispatch } from "react-redux";
import {
getUserPost,
getAllUser
} from "by-jsonplaceholderredux/actions/UserActions";
import { render } from "react-dom";
import store from "./store";
const App = () => {
return (
<Provider store={store}>
<TestComponent />
</Provider>
);
};
const TestComponent = () => {
const users = useSelector(state => state.user.users);
const userPosts = useSelector(state => state.user.userPosts);
const userPostsLoading = useSelector(
state => state.user.userPostsDataLoading
);
const dispatch = useDispatch();
React.useEffect(() => {
dispatch(getAllUser({}));
dispatch(getUserPost({ userId: 1 }));
}, []);
return (
<div>
<h1>User Count : {users.length}</h1>
<h1>
User Id: 1 Posts Count: {userPosts.length}{" "}
{userPostsLoading && "Loading..."}{" "}
</h1>
</div>
);
};
render(<App />, document.getElementById("root"));1.6.9
5 years ago
1.6.8
5 years ago
1.6.7
5 years ago
1.6.6
5 years ago
1.6.5
6 years ago
1.6.4
6 years ago
1.6.3
6 years ago
1.6.2
6 years ago
1.6.1
6 years ago
1.6.0
6 years ago
1.5.0
6 years ago
1.4.0
6 years ago
1.2.0
6 years ago
1.3.0
6 years ago
1.1.45
6 years ago
1.1.44
6 years ago
1.1.43
6 years ago
1.1.41
6 years ago
1.1.42
6 years ago
1.1.40
6 years ago
1.1.39
6 years ago
1.1.38
6 years ago
1.1.37
6 years ago
1.1.36
6 years ago
1.1.35
6 years ago
1.1.34
6 years ago
1.1.33
6 years ago
1.1.32
6 years ago
1.1.31
6 years ago
1.1.29
6 years ago
1.1.30
6 years ago
1.1.28
6 years ago
1.1.27
6 years ago
1.1.26
6 years ago
1.1.25
6 years ago
1.1.24
6 years ago
1.1.23
6 years ago
1.1.22
6 years ago
1.1.21
6 years ago
1.1.20
6 years ago
1.1.19
6 years ago
1.1.18
6 years ago
1.1.17
6 years ago
1.1.14
6 years ago
1.1.12
6 years ago
1.1.11
6 years ago
1.1.10
6 years ago
1.1.9
6 years ago
1.1.8
6 years ago
1.1.7
6 years ago
1.1.6
6 years ago
1.1.5
6 years ago
1.1.4
6 years ago
1.1.3
6 years ago
1.1.2
6 years ago