我react-redux-notify用来在我的应用程序中显示通知。我正在为我的应用程序使用功能组件。我已经按照他们的 Github repo 中给出的所有指南进行操作。我在下面分享了我的代码。
combineReducers.js
import { combineReducers } from 'redux';
import notifyReducer from 'react-redux-notify';
import reducer from './reducer';
export default combineReducers({
rootReducer: reducer,
notifications: notifyReducer,
});
我已经在我的商店中包含了那个减速器
我的组件代码
import React from 'react';
import { connect } from 'react-redux';
import { Notify } from 'react-redux-notify';
import {
createNotification,
NOTIFICATION_TYPE_SUCCESS,
} from 'react-redux-notify';
const mySuccessNotification = {
message: 'You have been logged in!',
type: NOTIFICATION_TYPE_SUCCESS,
duration: 0,
canDismiss: true,
icon: <i className="fa fa-check" />,
};
function createRestaurantSetup(props) {
function changeState() {
console.log('state event called');
createNotification(mySuccessNotification);
}
return (
<div className={classes.root}>
<Notify />
<Button type="submit" size="small" color="primary" onClick={changeState}>
Start Setting
</Button>
</div>
);
}
我没有收到任何changeState功能错误。但通知也没有显示