Skip to content

Instantly share code, notes, and snippets.

View Manntrix's full-sized avatar
🏠
Working from home

React Developer Manntrix

🏠
Working from home
View GitHub Profile
@Manntrix
Manntrix / users.js
Last active May 1, 2020 18:25
users.js
import React, {Component} from 'react'
import axios from '../../axios'
export default class users extends Component {
constructor(props) {
super(props);
this.state = {
Users: []
};
}
import {createStore, applyMiddleware} from 'redux'
import thunk from 'redux-thunk'
import {composeWithDevTools} from 'redux-devtools-extension'
import rootReducer from './reducers'
const initalState = {
}
import { combineReducers } from 'redux'
import userReducer from './usersReducer'
export default combineReducers({
users: userReducer
})
export const GET_USERS = 'GET_USERS';
export const USERS_ERROR = 'USERS_ERROR'
import {GET_USERS} from '../types'
const initialState = {
users:[],
loading:true
}
export default function(state = initialState, action){
switch(action.type){
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
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>
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() {
import React from 'react';
import './App.css';
import Users from './component/users'
function App() {
return (
<div className="App">
constructor(props){
super(props)
this.state = {
selectOptions : [],
id: "",
name: ''
}
}