Minimal starter boilerplate project with React, Redux, React Router and Auth0 authentication
A live demo of this project with a simple Facebook login via Auth0 is available here: https://react-redux-auth0.firebaseapp.com.
First create an auth0 account. Then run the following commands. Make sure your src/utils/config.js
file has the correct values from your auth0 account.
# Install dependencies
npm install
# Copy configuration and replace with your own
cp src/utils/config.example.js src/utils/config.js
# Run
npm start
Open http://localhost:3000
to see the app running.
Auth0 helps you to:
The library auth0-lock
provides the user authentication, and I also have a src/utils/AuthService.js
module to wrap this Lock Widget usage and manage the localStorage items.
I'm using the latest Auth0 Lock 10 version in popup mode, which means here's the flow:
This starter kit is minimal, only the strict necessary is added.
Library | Description |
---|---|
react | Facebook's library for building user interfaces |
redux | State container for JavaScript apps |
react-router | Declarative routing for React apps using navigational components |
create-react-app | All tooling needed for react apps |
The starter kit includes a working example app that puts all of the above to use.
create-react-app
takes care of tooling, development server, live reload, building, testing.
HMR is unfortunately not enabled during development, because create-react-app
doesn't support it.
If you wish to directly use Webpack instead of create-react-app
, you can eject any time by running npm run eject
. Read here for more information about ejecting.
npm run lint
to check linting errors. This projects follows eslint-config-react-app
style.
npm test
to run all tests. This project uses jest to run tests, and enzyme for unit testing React components.
Out of the box, this starter kit is deployable by serving the ~/build
folder generated by npm run build
.
MIT. See LICENSE file.
redux-saga
, redux-observable
) to manage side effects. It makes the code more redux-compliant, however it goes against minimalism.If you like this project, I would really appreciate small donations. Here's my Ethereum address: 0xa395447BF15f7525484C0378c76627D45ADE0B96.
React-redux 7.1发版啦。 因为在新的项目中用到了hooks,但是用的时候react-redux还处于alpha.x版本的状态。用不了最新的API,感觉不是很美妙。好在,这两天发布了7.1版本。 现在来看看怎么用这个新的API。 useSelector() const result : any = useSelector(selector : Function, equalityFn?
react-hooks 是 react 官方新的编写推荐,我们很容易在官方的 useReducer 钩子上进行一层很简单的封装以达到和以往 react-redux \ redux-thunk \ redux-logger 类似的功能,并且大幅度简化了声明。 安装 安装 react-hooks-redux, 需要 react 版本 >= 16.7 yarn add react-hooks-redux
// npm install --save redux-actions 1:作用: 当我们的在开发大型应用的时候,对于大量的action,我们的reducer需要些大量的swich来对action.type进行判断。 redux-actions可以简化这一烦琐的过程,它可以是actionCreator,也可以用来生成reducer, 其作用都是用来简化action、reducer。 主要函数有cr
Redux 状态管理器 集中式管理应用中的状态数据,以一种可预测的方式更新状态数据 react-redux 绑定库官网 redux 与 react 没有任何直接关系,所以在 react 中要使用 redux 进行状态管理,通常还需要额外的绑定库:react-redux 概念 store:仓库,是一个容器,主要用于集中管理应用中的状态 state:状态,是各组件需要共享的状态数据 action:是一
目录 为何组件没有被重新渲染、或者 mapStateToProps 没有运行? 为何组件频繁的重新渲染? 怎样使 mapStateToProps 执行更快? 为何不在被连接的组件中使用 this.props.dispatch ? 应该只连接到顶层组件吗,或者可以在组件树中连接到不同组件吗? React Redux 为何组件没有被重新渲染、或者 mapStateToProps 没有运行? 目前来看,
Universal React Redux Boilerplate A universal React/Redux boilerplate with sensible defaults. Out of the box, thisboilerplate comes with: Server-side rendering with Express Code splitting with dynamic
React-Redux-Enterprise A React-Redux boilerplate for enterprise web applications. Before you start with this boilerplate, please take a few minutes to read this article and see if you really need this
Live redux-react-starter This repository contains the minimal app to get started with redux, react, hot-reloading, async function and some other great stuffs. How to yarn 0.18+ must be present on your
React/Redux Links Curated tutorial and resource links I've collected on React, Redux, ES6, and more, meant to be a collection of high-quality articles and resources for someone who wants to learn abou
React Redux Saucepan A minimal Universal React redux JS stack using Flow, with hot reloading, linting and server-side rendering. This is a universal react project. It provides server-side rendering an