sorrycc / blog

💡

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

在umi 的项目中无法使用redux-modal

Meoworu opened this issue · comments

app.js 注入modalReducer
`export const dva = {
config: {
extraReducers: {
modal: modalReducer,
},
onError(e) {
e.preventDefault();
if (sentry) {
console.log('sentry', e.message);
}
},
// 注释以下可关闭logger
// onAction: createLogger(loggerConfig),

},

};`

modal.jsx
`import React from 'react';
import { connect } from 'dva';
import { connectModal } from 'redux-modal';
import { Modal } from 'antd';

function FollowUp(props:any) {
console.log(props);
function cancel (){
props.handleHide()
}
return (
<Modal
title="实战"
visible={true}
onCancel={() => {}}

<div>hello world</div>
) }

// export default connect((state:any) => state)(FollowUp);

export default connectModal({
name: 'follow-up',
destroyOnHide: true,
})(FollowUp);
`

ErrorBoundary.jsx
return ( <> {this.props.children} <Modals/> </> )

报告错误:
Error: Could not find "store" in the context of "Connect(ConnectModal(FollowUp))". Either wrap the root component in a , or pass a custom React context provider to and the corresponding React context consumer to Connect(ConnectModal(FollowUp)) in connect options.