Skip to content

Commit bc08831

Browse files
docs: update docs to reflect latest changes (#389)
1 parent a937b2a commit bc08831

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ or
2828
$ yarn add redux-actions
2929
```
3030

31-
The [npm](https://www.npmjs.com) package provides a [CommonJS](http://webpack.github.io/docs/commonjs.html) build for use in Node.js, and with bundlers like [Webpack](http://webpack.github.io/) and [Browserify](http://browserify.org/). It also includes an [ES modules](http://jsmodules.io/) build that works well with [Rollup](http://rollupjs.org/) and [Webpack2](https://webpack.js.org)'s tree-shaking.
32-
33-
The [UMD](https://unpkg.com/redux-actions@latest/dist) build exports a global called `window.ReduxActions` if you add it to your page via a `<script>` tag. We _don’t_ recommend UMD builds for any serious application, as most of the libraries complementary to Redux are only available on [npm](https://www.npmjs.com/search?q=redux).
31+
The [npm](https://www.npmjs.com) package provides [ES modules](http://jsmodules.io/) that should be compatible with every modern build tooling.
3432

3533
## Usage
3634

docs/introduction/Tutorial.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,33 @@ For Yarn users
1414
$ yarn add redux-actions
1515
```
1616

17-
For UMD users
18-
19-
The [UMD](https://unpkg.com/redux-actions@latest/dist) build exports a global called `window.ReduxActions` if you add it to your page via a `<script>` tag. We _don’t_ recommend UMD builds for any serious application, as most of the libraries complementary to Redux are only available on [npm](https://www.npmjs.com/search?q=redux).
20-
2117
### Vanilla Counter
2218

23-
We are going to be building a simple counter, I recommend using something like [jsfiddle](https://jsfiddle.net/) or [codepen](https://codepen.io/pen/) or [codesandbox](https://codesandbox.io) if you would like to follow along, that way you do not need a complicated setup to grasp the basics of `redux-actions`.
19+
We are going to be building a simple counter, you can find the final working example here:
20+
21+
<iframe src="https://codesandbox.io/embed/redux-actions-example-ztg7qp?fontsize=14&hidenavigation=1&theme=dark"
22+
style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;"
23+
title="redux-actions-example"
24+
allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking"
25+
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
26+
></iframe>
2427
2528
To begin we are going to need some scaffolding so here is some HTML to get started with. You may need to create a new file called main.js depending on where you are trying to set this tutorial up.
2629

2730
```html
2831
<!DOCTYPE html>
2932
<html>
3033
<head>
31-
<meta charset="utf-8" />
32-
<script src="https://unpkg.com/redux@latest/dist/redux.js"></script>
33-
<script src="https://unpkg.com/redux-actions@latest/dist/redux-actions.js"></script>
34+
<title>Redux Actions Example</title>
35+
<meta charset="UTF-8" />
3436
</head>
37+
3538
<body>
3639
<button id="increment">INCREMENT</button>
3740
<button id="decrement">DECREMENT</button>
38-
<div id="content" />
39-
<script src="main.js"></script>
41+
<div id="content"></div>
42+
43+
<script src="src/index.js"></script>
4044
</body>
4145
</html>
4246
```
@@ -59,18 +63,18 @@ const render = () => {
5963
render();
6064
```
6165

62-
With our default state and renderer in place we can start to use our libraries. `redux` and `redux-actions` can be found via the globals `window.Redux` and `window.ReduxActions`. Okay enough setup lets start to make something with `redux`!
66+
With our default state and renderer in place we can start to use our libraries. `redux` and `redux-actions`. Okay enough setup lets start to make something with `redux`!
6367

6468
We are going to want a store for our defaultState. We can create one from `redux` using `createStore`.
6569

6670
```js
67-
const { createStore } = window.Redux;
71+
import { createStore } from 'redux';
6872
```
6973

7074
We are going to want to create our first action and handle that action.
7175

7276
```js
73-
const { createAction, handleAction } = window.ReduxActions;
77+
import { createAction, handleAction } from 'redux-actions';
7478
```
7579

7680
Next lets create our first action, 'increment', using `createAction`.
@@ -127,7 +131,7 @@ const decrement = createAction('DECREMENT');
127131
Instead of using `handleAction` like we did for `increment`, we can replace it with our other tool `handleActions` which will let us handle both `increment` and `decrement` actions.
128132

129133
```js
130-
const { createAction, handleActions } = window.ReduxActions;
134+
import { createAction, handleActions } from 'redux-actions';
131135

132136
const reducer = handleActions(
133137
{
@@ -151,7 +155,7 @@ You might be thinking at this point we are all done. We have both buttons hooked
151155
We have declarations for both `increment` and `decrement` action creators. We can modify these lines from using `createAction` to using `createActions` like so.
152156

153157
```js
154-
const { createActions, handleActions } = window.ReduxActions;
158+
import { createActions, handleActions } from 'redux-actions';
155159

156160
const { increment, decrement } = createActions('INCREMENT', 'DECREMENT');
157161
```
@@ -180,7 +184,7 @@ const reducer = handleActions(
180184
Now that we have moved our logic, our `reducers` are looking identical. If only we could combine them somehow. Well we can! `combineActions` can be used to reduce multiple distinct actions with the same reducer.
181185

182186
```js
183-
const { createActions, handleActions, combineActions } = window.ReduxActions;
187+
import { createActions, handleActions, combineActions } from 'redux-actions';
184188

185189
const reducer = handleActions(
186190
{

0 commit comments

Comments
 (0)