This file contains 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 React, {Component} from 'react' | |
import axios from '../../axios' | |
export default class users extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
Users: [] | |
}; | |
} |
This file contains 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 {createStore, applyMiddleware} from 'redux' | |
import thunk from 'redux-thunk' | |
import {composeWithDevTools} from 'redux-devtools-extension' | |
import rootReducer from './reducers' | |
const initalState = { | |
} |
This file contains 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 { combineReducers } from 'redux' | |
import userReducer from './usersReducer' | |
export default combineReducers({ | |
users: userReducer | |
}) |
This file contains 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 GET_USERS = 'GET_USERS'; | |
export const USERS_ERROR = 'USERS_ERROR' |
This file contains 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 {GET_USERS} from '../types' | |
const initialState = { | |
users:[], | |
loading:true | |
} | |
export default function(state = initialState, action){ | |
switch(action.type){ |
This file contains 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 {GET_USERS, USERS_ERROR} from '../types' | |
import axios from 'axios' | |
export const getUsers = () => async dispatch => { | |
try{ | |
const res = await axios.get(`http://jsonplaceholder.typicode.com/users`) | |
dispatch( { | |
type: GET_USERS, | |
payload: res.data |
This file contains 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 React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import './index.css'; | |
import App from './App'; | |
import * as serviceWorker from './serviceWorker'; | |
import store from './store/store' | |
import {Provider} from 'react-redux'; | |
ReactDOM.render( | |
<React.StrictMode> |
This file contains 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 React, { Component } from 'react' | |
import {connect} from 'react-redux' | |
import {getUsers} from '../store/actions/usersAction' | |
class users extends Component { | |
componentDidMount(){ | |
this.props.getUsers() | |
} | |
render() { |
This file contains 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 React from 'react'; | |
import './App.css'; | |
import Users from './component/users' | |
function App() { | |
return ( | |
<div className="App"> |
This file contains 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
constructor(props){ | |
super(props) | |
this.state = { | |
selectOptions : [], | |
id: "", | |
name: '' | |
} | |
} |