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-jsonplaceholderredux
Usage
// 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
5 years ago
1.6.4
5 years ago
1.6.3
5 years ago
1.6.2
5 years ago
1.6.1
5 years ago
1.6.0
5 years ago
1.5.0
5 years ago
1.4.0
5 years ago
1.2.0
5 years ago
1.3.0
5 years ago
1.1.45
5 years ago
1.1.44
5 years ago
1.1.43
5 years ago
1.1.41
5 years ago
1.1.42
5 years ago
1.1.40
5 years ago
1.1.39
5 years ago
1.1.38
5 years ago
1.1.37
5 years ago
1.1.36
5 years ago
1.1.35
5 years ago
1.1.34
5 years ago
1.1.33
5 years ago
1.1.32
5 years ago
1.1.31
5 years ago
1.1.29
5 years ago
1.1.30
5 years ago
1.1.28
5 years ago
1.1.27
5 years ago
1.1.26
5 years ago
1.1.25
5 years ago
1.1.24
5 years ago
1.1.23
5 years ago
1.1.22
5 years ago
1.1.21
5 years ago
1.1.20
5 years ago
1.1.19
5 years ago
1.1.18
5 years ago
1.1.17
5 years ago
1.1.14
5 years ago
1.1.12
5 years ago
1.1.11
5 years ago
1.1.10
5 years ago
1.1.9
5 years ago
1.1.8
5 years ago
1.1.7
5 years ago
1.1.6
5 years ago
1.1.5
5 years ago
1.1.4
5 years ago
1.1.3
5 years ago
1.1.2
5 years ago