This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Store: | |
Users: | |
actionTypes.js | |
actions.js | |
reducers.js | |
selectors.js | |
service.js | |
Posts: | |
actionTypes.js | |
actions.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JsonPlaceHolderService{ | |
static getPosts(){ | |
const url = 'https://jsonplaceholder.typicode.com/posts' | |
//define my request | |
const request = { | |
method: "GET", | |
}; | |
//make the call and return a json object of the response | |
return fetch(url, request) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const POSTS_REQUESTED = 'posts.POSTS_REQUESTED' | |
export const POSTS_RECEIVED = 'posts.POSTS_RECEIVED' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as types from "./actionTypes" | |
import JsonPlaceHolderService from "./service" | |
export function fetchPosts(){ | |
return function(dispatch, getState){ | |
//dispatch an action to show the starte | |
dispatch({type: types.POSTS_REQUESTED}) | |
return JsonPlaceHolderService.getPosts() | |
.then(posts =>{ | |
dispatch({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as types from "./actionTypes" | |
import Immutable from "seamless-immutable" | |
const initialState = Immutable({ | |
posts: undefined, | |
postsIsFetched: false | |
}) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function getPosts(state){ | |
return state.postsReducer.posts | |
} | |
export function getPostStatus(state){ | |
return state.postsReducer.postsIsFetched | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { connect } from 'react-redux' | |
import React, { Component } from "react" | |
import { bindActionCreators } from "redux" | |
//import actions and selectors from the Store folder | |
import * as postActions from "../Store/Posts/actions" | |
import * as postSelectors from "../Store/Posts/selectors" | |
//import your component | |
import PostItem from "../Components/PostItem" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"lastUpload":"2021-03-08T16:19:35.628Z","extensionVersion":"v3.4.3"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { render } from "react-dom" | |
import React from "react" | |
import { Provider } from "react-redux" | |
import { combineReducers, createStore, applyMiddleware } from "redux" | |
import thunk from 'redux-thunk' | |
//import the post screen | |
import PostScreen from "Containers/PostScreen" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const isNull = value => { | |
return value === null; | |
}; | |
export const isUndefined = value => { | |
return typeof value === "undefined"; | |
}; | |
export const isString = value => { | |
return typeof value === "string" || value instanceof String; | |
}; | |
export const isNumber = value => { |
OlderNewer