Reactjs React redux通知重新匹配问题
使用rematch:redux框架从模型构建存储时呈现Notify(在单击时触发的通知组件)组件时遇到问题<代码>调度(createNotification(config))正在被触发,但未更新状态。知道为什么吗?我的猜测是重新匹配框架没有正确绑定。在redux开发工具中,我得到的是: 行动:Reactjs React redux通知重新匹配问题,reactjs,redux,react-redux,rematch,react-redux-notify,Reactjs,Redux,React Redux,Rematch,React Redux Notify,使用rematch:redux框架从模型构建存储时呈现Notify(在单击时触发的通知组件)组件时遇到问题调度(createNotification(config))正在被触发,但未更新状态。知道为什么吗?我的猜测是重新匹配框架没有正确绑定。在redux开发工具中,我得到的是: 行动: ADD_NOTIFICATION // action being dispatched type(pin): "ADD_NOTIFICATION" notification: message(pin): "TH
ADD_NOTIFICATION // action being dispatched
type(pin): "ADD_NOTIFICATION"
notification:
message(pin): "THIS NOTIFICATION WORKS!"
type(pin): "SUCCESS"
duration(pin): 0
canDismiss(pin): true
icon: { ... }
id(pin): 1537900315811
声明:
Notifications: [] // not being updated when ADD_NOTIFICATIONS triggers
models/notifications.js
store.js
容器/ExampleComponentContainer.js
组件/示例组件
从'react redux Notify'导入{Notify,NOTIFICATION_TYPE_SUCCESS};
类ExampleComponent扩展了React.Component{
成功通知={
信息:“它有效!”,
类型:通知类型成功,
持续时间:0,
老实说,
偶像:
}
handleClick=()=>{
const{createNotification}=this.props;
createNotification(mySuccessNotification);
}
render(){
返回(
发送通知!
)
}
}
import notifyReducer from 'react-redux-notify'
export default {
state: [],
reducers: { notifyReducer },
}
import { init } from '@rematch/core'
import notifications as models from './models'
const store = init({ models })
export default store
import { connect } from 'react-redux'
import { createNotification } from 'react-redux-notify'
import ExampleComponent from '../../components/ExampleComponent'
import store from '../../store'
const { dispatch } = store
const mapStateToProps = ({ notifications }) => ({ notifications })
const mapDispatchToProps = ({}) => ({
createNotification: config => {
dispatch(createNotification(config))
},
})
export default connect(
mapStateToProps,
mapDispatchToProps,
)(ExampleComponent)
import { Notify, NOTIFICATION_TYPE_SUCCESS } from 'react-redux-notify';
class ExampleComponent extends React.Component {
successNotification = {
message: 'IT WORKS!',
type: NOTIFICATION_TYPE_SUCCESS,
duration: 0,
canDismiss: true,
icon: <i className="fa fa-check" />
}
handleClick = () => {
const {createNotification} = this.props;
createNotification(mySuccessNotification);
}
render(){
return (
<div>
<Notify />
<button onClick={this.handleClick()}>Dispatch Notification!
</button>
</div>
)
}
}