Skip to content

WIP: examples folder refactoring #3919

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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 21 additions & 48 deletions docs/introduction/Examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ Or check out the [sandbox](https://codesandbox.io/s/github/reduxjs/redux/tree/ma

<iframe class="codesandbox"src="https://codesandbox.io/embed/github/reduxjs/redux/tree/master/examples/counter"sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>

This is the most basic example of using Redux together with React. For simplicity, it re-renders the React component manually when the store changes. In real projects, you will likely want to use the highly performant [React Redux](https://github.com/reduxjs/react-redux) bindings instead.
This is the most basic example of using Redux together with React and it's also a `create-react-app` template.
So it's the same code you'd get running `npx create-react-app my-app --template redux`

This example includes tests.

Expand Down Expand Up @@ -84,44 +85,6 @@ Or check out the [sandbox](https://codesandbox.io/s/github/reduxjs/redux/tree/ma

This is a variation on the previous example. It is almost identical, but additionally shows how wrapping your reducer with [Redux Undo](https://github.com/omnidan/redux-undo) lets you add a Undo/Redo functionality to your app with a few lines of code.

## Todos w/ Flow

Run the [Todos w/ Flow](https://github.com/reduxjs/redux/tree/master/examples/todos-flow) example:

```sh
git clone https://github.com/reduxjs/redux.git

cd redux/examples/todos-flow
npm install
npm start
```

Or check out the [sandbox](https://codesandbox.io/s/github/reduxjs/redux/tree/master/examples/todos-flow):

<iframe class="codesandbox"src="https://codesandbox.io/embed/github/reduxjs/redux/tree/master/examples/todos-flow"sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>

This is like the previous Todos examples, but shows how to use Redux in conjunction with [Flow](https://flow.org/).

## TodoMVC

Run the [TodoMVC](https://github.com/reduxjs/redux/tree/master/examples/todomvc) example:

```sh
git clone https://github.com/reduxjs/redux.git

cd redux/examples/todomvc
npm install
npm start
```

Or check out the [sandbox](https://codesandbox.io/s/github/reduxjs/redux/tree/master/examples/todomvc):

<iframe class="codesandbox"src="https://codesandbox.io/embed/github/reduxjs/redux/tree/master/examples/todomvc"sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>

This is the classical [TodoMVC](http://todomvc.com/) example. It's here for the sake of comparison, but it covers the same points as the Todos example.

This example includes tests.

## Shopping Cart

Run the [Shopping Cart](https://github.com/reduxjs/redux/tree/master/examples/shopping-cart) example:
Expand Down Expand Up @@ -160,23 +123,33 @@ This example demonstrates rendering a deeply nested tree view and representing i

This example includes tests.

## Async
## Redux essentials

Run the [Async](https://github.com/reduxjs/redux/tree/master/examples/async) example:
The example app from the ["Redux Essentials" tutorial](../tutorials/essentials/part-1-overview-concepts.md) is a larger "real world"-type app that shows:

- Use of Redux Toolkit and the React Redux hooks API
- A "feature folder" structure with single-file "slices" for Redux logic
- Async logic, data fetching, and loading state
- CRUD operations
- Normalized state

Run the [Redux Essentials](https://github.com/reduxjs/redux-essentials-example-app) example:

<iframe class="codesandbox"src="https://codesandbox.io/embed/github/reduxjs/redux-essentials-example-app/tree/master"sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>

## Redux fundamentals

Run the [Redux fundamentals](https://github.com/reduxjs/redux-fundamentals-example-app) example:

```sh
git clone https://github.com/reduxjs/redux.git
git clone https://github.com/reduxjs/redux-fundamentals-example-app.git

cd redux/examples/async
cd redux-fundamentals-example-app
npm install
npm start
```

Or check out the [sandbox](https://codesandbox.io/s/github/reduxjs/redux/tree/master/examples/async):

<iframe class="codesandbox"src="https://codesandbox.io/embed/github/reduxjs/redux/tree/master/examples/async"sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>

This example includes reading from an asynchronous API, fetching data in response to user input, showing loading indicators, caching the response, and invalidating the cache. It uses [Redux Thunk](https://github.com/gaearon/redux-thunk) middleware to encapsulate asynchronous side effects.
<iframe class="codesandbox"src="https://codesandbox.io/embed/github/reduxjs/redux-fundamentals-example-app/tree/master"sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>

## Universal

Expand Down
11 changes: 0 additions & 11 deletions examples/async/.gitignore

This file was deleted.

36 changes: 1 addition & 35 deletions examples/async/README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1 @@
# Redux Async Example

This project template was built with [Create React App](https://github.com/facebookincubator/create-react-app), which provides a simple way to start React projects with no build configuration needed.

Projects built with Create-React-App include support for ES6 syntax, as well as several unofficial / not-yet-final forms of Javascript syntax such as Class Properties and JSX. See the list of [language features and polyfills supported by Create-React-App](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#supported-language-features-and-polyfills) for more information.

## 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.
### Go look at the real world example app -> [here](https://github.com/reduxjs/redux/tree/master/examples/real-world)
Loading