Skip to content

Instantly share code, notes, and snippets.

View aminbenselim's full-sized avatar

Amin Benselim aminbenselim

View GitHub Profile
@aminbenselim
aminbenselim / actions.js
Created March 26, 2017 20:18
Posts List and Single Post actions
//Post list
export const GET_POSTS = 'GET_POSTS';
export const GET_POSTS_SUCCESS = 'GET_POSTS_SUCCESS';
export const GET_POSTS_FAILURE = 'GET_POSTS_FAILURE';
//Single post
export const GET_POST = 'GET_POST';
export const GET_POST_SUCCESS = 'GET_POST_SUCCESS';
export const GET_POST_FAILURE = 'GET_POST_FAILURE';
@aminbenselim
aminbenselim / actionCreators.js
Created March 26, 2017 20:25
action creators for the different action types
import axios from 'axios';
import {
GET_POSTS,
GET_POSTS_SUCCESS,
GET_POSTS_FAILURE,
GET_POST,
GET_POST_SUCCESS,
GET_POST_FAILURE,
} from './actions';
import {
GET_POSTS,
GET_POSTS_SUCCESS,
GET_POSTS_FAILURE
} from "./../actions/actions";
const INITIAL_STATE = { posts: [], error: null, loading: false, totalpages: 0 };
const Posts = (state = INITIAL_STATE, action) => {
let error;
import {
GET_POST,
GET_POST_SUCCESS,
GET_POST_FAILURE,
} from "./../actions/actions";
const INITIAL_STATE = { post: null, error: null, loading: false };
const Post = (state = INITIAL_STATE, action) => {
let error;
@aminbenselim
aminbenselim / reducers.js
Created March 26, 2017 20:55
combine main reducers and single reducers
import { combineReducers } from "redux";
import MainReducer from "./reducer_main";
import SingleReducer from "./reducer_single";
const rootReducer = combineReducers({
postsList: MainReducer,
currentPost: SingleReducer
});
export default rootReducer;
import { createStore, applyMiddleware, compose } from "redux";
import reducers from "./../reducers/reducers";
import promise from "redux-promise";
const enhancer = applyMiddleware(promise);
export default function configureStore(initialState) {
return createStore(rootReducer, initialState, enhancer);
}
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { Router, browserHistory } from 'react-router';
import routes from './routes';
import configureStore from './store/configureStore.js';
const store = configureStore({});
ReactDOM.render(
import React from 'react';
import { Route, IndexRoute } from 'react-router';
import Main from './containers/maincontainer';
import Single from './containers/singlecontainer';
import App from './components/app';
import SingleWrapper from './components/singleContain';
import NotFound from './components/404';
export default (
var path = require("path");
var webpack = require("webpack");
module.exports = {
entry: "./index.js",
output: {
path: path.join(__dirname, "../js"),
filename: "bundle.js"
},
module: {