Skip to content

Instantly share code, notes, and snippets.

@jackinf
Created October 6, 2018 13:27
Show Gist options
  • Save jackinf/4f646f600422bfd7b7f07e5a717a6885 to your computer and use it in GitHub Desktop.
Save jackinf/4f646f600422bfd7b7f07e5a717a6885 to your computer and use it in GitHub Desktop.
React create app (Redux etc)
import React from 'react'
import { render } from 'react-dom'
import { Provider } from 'react-redux'
import { ConnectedRouter } from 'connected-react-router'
import store, { history } from './store'
import App from './containers/app'
import 'sanitize.css/sanitize.css'
import './index.css'
const target = document.querySelector('#root')
render(
<Provider store={store}>
<ConnectedRouter history={history}>
<div>
<App />
</div>
</ConnectedRouter>
</Provider>,
target
)
{
"type": "static",
"static": {
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
{
"private": true,
"homepage": "https://create-react-app-redux.now.sh",
"scripts": {
"deploy": "now && now alias",
"start": "react-scripts start",
"now-start": "serve -s ./build",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"precommit": "pretty-quick --staged"
},
"devDependencies": {
"prettier": "1.14.3",
"react-scripts": "2.0.4"
},
"dependencies": {
"connected-react-router": "4.5.0",
"react": "16.5.2",
"react-dom": "16.5.2",
"react-redux": "5.0.7",
"react-router": "4.3.1",
"react-router-dom": "4.3.1",
"redux": "4.0.0",
"redux-thunk": "2.3.0",
"sanitize.css": "7.0.3",
"serve": "10.0.2"
}
}
# Use Node.js version 10
FROM mhart/alpine-node:10
# Set the working directory
WORKDIR /usr/src
# Copy package manager files to the working directory and run install
COPY package.json yarn.lock ./
RUN yarn install
# Copy all files to the working directory
COPY . .
# Run tests
RUN CI=true yarn test
# Build the app and move the resulting build to the `/public` directory
RUN yarn build
RUN mv ./build /public
import { createStore, applyMiddleware, compose } from 'redux'
import { connectRouter, routerMiddleware } from 'connected-react-router'
import thunk from 'redux-thunk'
import createHistory from 'history/createBrowserHistory'
import rootReducer from './modules'
export const history = createHistory()
const initialState = {}
const enhancers = []
const middleware = [thunk, routerMiddleware(history)]
if (process.env.NODE_ENV === 'development') {
const devToolsExtension = window.__REDUX_DEVTOOLS_EXTENSION__
if (typeof devToolsExtension === 'function') {
enhancers.push(devToolsExtension())
}
}
const composedEnhancers = compose(
applyMiddleware(...middleware),
...enhancers
)
export default createStore(
connectRouter(history)(rootReducer),
initialState,
composedEnhancers
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment