1.6.9 • Published 4 years ago

edkk-redux v1.6.9

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

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

4 years ago

1.6.8

4 years ago

1.6.7

4 years ago

1.6.6

4 years ago

1.6.5

4 years ago

1.6.4

4 years ago

1.6.3

4 years ago

1.6.2

4 years ago

1.6.1

4 years ago

1.6.0

4 years ago

1.5.0

4 years ago

1.4.0

4 years ago

1.2.0

4 years ago

1.3.0

4 years ago

1.1.45

4 years ago

1.1.44

4 years ago

1.1.43

4 years ago

1.1.41

4 years ago

1.1.42

4 years ago

1.1.40

4 years ago

1.1.39

4 years ago

1.1.38

4 years ago

1.1.37

4 years ago

1.1.36

4 years ago

1.1.35

4 years ago

1.1.34

4 years ago

1.1.33

4 years ago

1.1.32

4 years ago

1.1.31

4 years ago

1.1.29

4 years ago

1.1.30

4 years ago

1.1.28

4 years ago

1.1.27

4 years ago

1.1.26

4 years ago

1.1.25

4 years ago

1.1.24

4 years ago

1.1.23

4 years ago

1.1.22

4 years ago

1.1.21

4 years ago

1.1.20

4 years ago

1.1.19

4 years ago

1.1.18

4 years ago

1.1.17

4 years ago

1.1.14

4 years ago

1.1.12

4 years ago

1.1.11

4 years ago

1.1.10

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago