32

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

 4 years ago
source link: https://github.com/sorrycc/blog/issues/94
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

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.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK