Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port examples to use Create React App #1883

Merged
merged 15 commits into from
Sep 2, 2016
8 changes: 0 additions & 8 deletions examples/async/.babelrc

This file was deleted.

11 changes: 11 additions & 0 deletions examples/async/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
node_modules

# production
build

# misc
.DS_Store
npm-debug.log
34 changes: 34 additions & 0 deletions examples/async/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Redux Async Example

This project template was built with [Create React App](https://github.com/facebookincubator/create-react-app).

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.<br>
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.<br>
You will also see any lint errors in the console.

### `npm run build`

Builds the app for production to the `build` folder.<br>
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.<br>
Your app is ready to be deployed!

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

22 changes: 16 additions & 6 deletions examples/async/index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
<!DOCTYPE html>
<html>
<!doctype html>
<html lang="en">
<head>
<title>Redux async example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Redux Async Example</title>
</head>
<body>
<div id="root">
</div>
<script src="/static/bundle.js"></script>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.

You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.

To begin the development, run `npm start` in this folder.
To create a production bundle, use `npm run build`.
-->
</body>
</html>
15 changes: 0 additions & 15 deletions examples/async/index.js

This file was deleted.

63 changes: 18 additions & 45 deletions examples/async/package.json
Original file line number Diff line number Diff line change
@@ -1,51 +1,24 @@
{
"name": "redux-async-example",
"version": "0.0.0",
"description": "Redux async example",
"scripts": {
"start": "node server.js"
},
"repository": {
"type": "git",
"url": "https://github.com/reactjs/redux.git"
},
"keywords": [
"react",
"reactjs",
"hot",
"reload",
"hmr",
"live",
"edit",
"webpack",
"flux"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/reactjs/redux/issues"
"name": "async",
"version": "0.0.1",
"private": true,
"devDependencies": {
"react-scripts": "^0.4.0",
"redux-logger": "^2.6.1"
},
"homepage": "http://redux.js.org",
"dependencies": {
"babel-polyfill": "^6.3.14",
"isomorphic-fetch": "^2.1.1",
"react": "^0.14.7",
"react-dom": "^0.14.7",
"react-redux": "^4.2.1",
"redux": "^3.2.1",
"redux-logger": "^2.4.0",
"redux-thunk": "^1.0.3"
"react": "^15.3.0",
"react-dom": "^15.3.0",
"react-redux": "^4.4.5",
"redux": "^3.5.2",
"redux-thunk": "^2.1.0"
},
"devDependencies": {
"babel-core": "^6.3.15",
"babel-loader": "^6.2.0",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babel-preset-react-hmre": "^1.1.1",
"expect": "^1.6.0",
"express": "^4.13.3",
"node-libs-browser": "^0.5.2",
"webpack": "^1.9.11",
"webpack-dev-middleware": "^1.2.0",
"webpack-hot-middleware": "^2.9.1"
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "./node_modules/react-scripts/config/eslint.js"
}
}
23 changes: 0 additions & 23 deletions examples/async/server.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import fetch from 'isomorphic-fetch'

export const REQUEST_POSTS = 'REQUEST_POSTS'
export const RECEIVE_POSTS = 'RECEIVE_POSTS'
export const SELECT_REDDIT = 'SELECT_REDDIT'
Expand Down
File renamed without changes.
25 changes: 25 additions & 0 deletions examples/async/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react'
import { render } from 'react-dom'
import { createStore, applyMiddleware } from 'redux'
import { Provider } from 'react-redux'
import thunk from 'redux-thunk'
import createLogger from 'redux-logger'
import reducer from './reducers'
import App from './containers/App'

const middleware = [ thunk ]
if (process.env.NODE_ENV !== 'production') {
middleware.push(createLogger())
}

const store = createStore(
reducer,
applyMiddleware(...middleware)
)

render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('root')
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,24 @@ function posts(state = {
}, action) {
switch (action.type) {
case INVALIDATE_REDDIT:
return Object.assign({}, state, {
return {
...state,
didInvalidate: true
})
}
case REQUEST_POSTS:
return Object.assign({}, state, {
return {
...state,
isFetching: true,
didInvalidate: false
})
}
case RECEIVE_POSTS:
return Object.assign({}, state, {
return {
...state,
isFetching: false,
didInvalidate: false,
items: action.posts,
lastUpdated: action.receivedAt
})
}
default:
return state
}
Expand All @@ -45,9 +48,10 @@ function postsByReddit(state = { }, action) {
case INVALIDATE_REDDIT:
case RECEIVE_POSTS:
case REQUEST_POSTS:
return Object.assign({}, state, {
return {
...state,
[action.reddit]: posts(state[action.reddit], action)
})
}
default:
return state
}
Expand Down
22 changes: 0 additions & 22 deletions examples/async/store/configureStore.js

This file was deleted.

29 changes: 0 additions & 29 deletions examples/async/webpack.config.js

This file was deleted.

8 changes: 0 additions & 8 deletions examples/counter/.babelrc

This file was deleted.

11 changes: 11 additions & 0 deletions examples/counter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
node_modules

# production
build

# misc
.DS_Store
npm-debug.log
33 changes: 33 additions & 0 deletions examples/counter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Redux Counter Example

This project template was built with [Create React App](https://github.com/facebookincubator/create-react-app).

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.<br>
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.<br>
You will also see any lint errors in the console.

### `npm run build`

Builds the app for production to the `build` folder.<br>
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.<br>
Your app is ready to be deployed!

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
Loading