redux

Why are pure reducers so important in redux?

不羁的心 提交于 2020-02-23 10:12:14
问题 Pure reducers have no side effects and enable things like time-travelling. They make reasoning about application behavior easier. This is intuitive to me. But I cannot articulate WHY pure reducers lead to these positive non-functional attributes. Can someone help me articulate why making reducers side-effect free makes reasoning about application behavior easier? Is it because you are guaranteed to have the exact same state after running the reducers? If so, surely even side-effectful (ie.

Typescript module has no exported members - react

余生颓废 提交于 2020-02-23 09:16:30
问题 I am working on a react, redux Typescript application. I have a strange situation where after some changes one of the modules has stopped exporting its members. The folder structure is: src |---- components |---- containers The 'components' folder has the .tsx files while the wrapping .ts files are in the 'containers' folder. The module NodeList.tsx is listed below: import * as React from "react"; export const NodeList = (props) => ( <div id="NodeList"> <ul> {props.items.map((item, i) => (

Typescript module has no exported members - react

不问归期 提交于 2020-02-23 09:14:06
问题 I am working on a react, redux Typescript application. I have a strange situation where after some changes one of the modules has stopped exporting its members. The folder structure is: src |---- components |---- containers The 'components' folder has the .tsx files while the wrapping .ts files are in the 'containers' folder. The module NodeList.tsx is listed below: import * as React from "react"; export const NodeList = (props) => ( <div id="NodeList"> <ul> {props.items.map((item, i) => (

React - Communication and routing between components published as npm packages

ぃ、小莉子 提交于 2020-02-22 05:44:46
问题 I am trying to setup micro-frontend architecture for the project. The project contains multiple react apps. Following is the project structure: container header (npm package) dashboard (npm package) app1 (npm package) app2 (npm package) app3 (npm package) Here, container works as wrapper for the other apps. Dashboard apps shows links to the other apps such as app1, app2, app3 etc... Once user logs in header and dashboard app renders on a page. From dashboard user can navigate to other apps.

React之 redux 的简单介绍及使用

杀马特。学长 韩版系。学妹 提交于 2020-02-22 02:53:46
1、为什么使用redux? 在小型react项目的开发中 ,view(视图层)中的数据模型(即数据),可以存放在组件中的 state 对象,换句话说页面中的动态数据存放在 state 中。 但对于开发大型复杂的项目来说,单页面管理的状态(state)会有很多很多。管理不断变化的状态非常困难,状态的改变可能会引起页面的变化, 而页面的变化也会引起状态的变化,这种变化异常复杂,以至于我们很难捋清业务实现功能,为此我们用到了 redux,使用 redux 管理大量的状态(state)。 2、什么情况下不使用redux? UI层非常简单(页面动态数据少) 不需要与服务器大量交互,也没有使用WebSocket view(视图层)数据来源是单一的。 3、什么情况下要使用 redux? 某个组件的状态需要共享 某个状态需要在任何地方都可以拿到 一个组件需要改变全局状态 一个组件需要改变另一个组件的状态 4、redux 的实现原理是什么 ? 我们知道视图的数据来源于state,或者说是一一对应的。redux 只是把所有复杂的状态抽离出来保存在一个对象里面, 当视图层需要用到数据的时候,通过模块导入这个对象即可。 5、在使用 redux 之前我们需要了解 redux 模块中的几个基本概念。 ① Store 可以看作为 redux 的核心,因为它是存放数据的地方

React Redux学习记录

感情迁移 提交于 2020-02-22 02:51:58
原文: https://www.jianshu.com/p/81e9e9eaf8fa connect() React-Redux 提供connect方法,用于从 UI 组件生成容器组件。connect的意思,就是将这两种组件连起来。 import { connect } from 'react-redux' const VisibleTodoList = connect()(TodoList); 上面代码中,TodoList是 UI 组件,VisibleTodoList就是由 React-Redux 通过connect方法自动生成的容器组件。 但是由于没有定义业务逻辑,上面这个 容器组件没有实际yiyi,为了实现业务逻辑,需要满足厦门的信息 1)输入逻辑,外部的数据(state对象)转换为UI组件的参数 2)输出逻辑,用户发出的动作怎么变成Action对象,从UI组件传出去 完整的connect方法 import { connect } from 'react-redux' const VisibleTodoList = connect( mapStateToProps, mapDispatchToProps )(TodoList)  mapStateToProps负责输入逻辑 state映射到UI组件的参数(props) mapDispatchToProps 负责输出逻辑

TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received type undefined raised when starting react app

假如想象 提交于 2020-02-21 08:19:47
问题 I'm working on a project in React and ran into a problem that has me stumped. Whenever I run yarn start I get this error: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined I have no idea why this is happening, if anyone has experienced this I would be grateful. 回答1: To fix this issue simply upgrade to "react-scripts": "^3.4.0" Overwrite the existing "react-scripts": "^3.x.x" with "react-scripts": "^3.4.0" in your package.json Delete your

TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received type undefined raised when starting react app

限于喜欢 提交于 2020-02-21 08:18:12
问题 I'm working on a project in React and ran into a problem that has me stumped. Whenever I run yarn start I get this error: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined I have no idea why this is happening, if anyone has experienced this I would be grateful. 回答1: To fix this issue simply upgrade to "react-scripts": "^3.4.0" Overwrite the existing "react-scripts": "^3.x.x" with "react-scripts": "^3.4.0" in your package.json Delete your

TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received type undefined raised when starting react app

非 Y 不嫁゛ 提交于 2020-02-21 08:17:57
问题 I'm working on a project in React and ran into a problem that has me stumped. Whenever I run yarn start I get this error: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined I have no idea why this is happening, if anyone has experienced this I would be grateful. 回答1: To fix this issue simply upgrade to "react-scripts": "^3.4.0" Overwrite the existing "react-scripts": "^3.x.x" with "react-scripts": "^3.4.0" in your package.json Delete your

Access Redux store in JavaScript function

爱⌒轻易说出口 提交于 2020-02-20 03:41:35
问题 Is it possible to map redux state to a regular javascript function rather than a React component? If not, is there another way for connecting redux state to a function? (obviously without explicitly passing it in as a param) I have tried connecting to a function, but it breaks (I don't have an exact error message. the server just hits an uncaughtException). Since React components can be pure functions, does connect() only work with a class ComponentName extends Component (and the likes)? The