Skip to content

Commit a33a9de

Browse files
committed
add action creator
1 parent f93d1b7 commit a33a9de

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

server/client/src/actions/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import axios from 'axios';
22
import { FETCH_USER } from './types';
33

4-
const fetchUser = () => {
4+
export const fetchUser = () => {
55
return function(dispatch) {
66
axios
77
.get('/api/current_user')

server/client/src/components/App.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
import React, { Component } from 'react';
22
import { BrowserRouter, Route } from 'react-router-dom';
3+
import { connect } from 'react-redux';
4+
import * as actions from '../actions';
35

46
import Header from './Header';
57
const Dashboard = () => <h2>Dashboard</h2>;
68
const SurveyNew = () => <h2>SurveyNew</h2>;
79
const Landing = () => <h2>Landing</h2>;
810

911
class App extends Component {
12+
componentDidMount() {
13+
this.props.fetchUser();
14+
}
15+
1016
render() {
1117
return (
1218
<div className="container">
@@ -23,4 +29,4 @@ class App extends Component {
2329
}
2430
}
2531

26-
export default App;
32+
export default connect(null, actions)(App);

server/client/src/reducers/authReducer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export default function(state = {}, action) {
2+
console.log(action);
23
switch (action.type) {
34
default:
45
return state;

0 commit comments

Comments
 (0)