我一直在学习Redux,我不清楚的是,我如何在使用react状态与redux存储之间做出决定,然后分派操作。到目前为止,从我的阅读来看,我可以使用React状态来代替Redux store,并且仍然可以完成任务。我理解使用Redux store的关注点分离,只有一个容器组件,其余的作为无状态组件,但我不是很清楚如何确定何时使用React state Vs redux store。有人能帮帮忙吗?
谢谢!
我正在尝试学习redux表单和typescript,但我遇到了一个我无法解决的错误。 错误是:Property 'submitAction' is missing in type '{}' but required in type 'Readonly<IDispatchProps & Partial<ConfigProps<IUser, IDispatchProps, string>>>'.ts(2741) 这就是我认为错误的地方。 //Form.tsx import * as React from
我使用了react、redux和react-redux-router。当我运行一个应用程序时,我得到一个错误。我不明白它与我的App.js中react的呈现功能有什么关系。在我看来,问题出在代码的其他地方。
错误如下:
Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of `App`
import React from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import { setLocation } from 'redux/modules/filters'
import SearchForm from 'components/SearchForm/SearchForm'
type Props = {
};
export class HomeSearch
我是跟随视频教程上的Redux。我和教程中的人完全一样遵循代码,但是当应用程序呈现错误时,我会说-
TypeError: undefined is not an object (evaluating 'this.state'
下面是错误堆栈:
下面是我为组件使用的代码:
import React from 'react'
import {View, Text, StyleSheet, TextInput, TouchableOpacity} from 'react-native'
import {Ionicons} from '
react版本为16.13.1。
我想知道在异步方法中使用redux是否有一些好处。
const component = () => {
const asyncFunc = async() => { // <- this part should be moved out to redux-saga?
await callMethod();
}
return (
<div onClick={asyncFunc}>button</div>
)
}
我不知道应该在redux或react组件中调用asyncFunc。
哪个
这是我的app.js
import React from 'react'
import { Provider } from 'react-redux'
import { View } from 'react-native'
import { createStore, applyMiddleware } from 'redux'
import ReduxThunk from 'redux-thunk'
import Reducers from './redux'
import Routes from