我正在尝试使用 react-plaid-link 将 plaid 集成到我的应用程序中。在我执行 handleOnSuccess 回调之前,一切正常。我收到以下错误消息:
未捕获的类型错误:无法读取未定义的属性“createTransferSource”
由于某种原因,当我调用 handleOnSuccess 时,从“../../actions”导出的动作创建者不可用
这是我的组件
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import PlaidLink from 'react-plaid-link';
import * as actions from '../../actions';
const plaidPublicKey = process.env.REACT_APP_PLAID_PUBLIC_KEY;
class PlaidAuthComponent extends Component {
handleOnSuccess(token, metadata) {
// send token to client server
this.props.createTransferSource(metadata);
}
render() {
return (
<div>
<PlaidLink
publicKey={`${plaidPublicKey}`}
product="auth"
env="sandbox"
clientName="plaidname"
onSuccess={this.handleOnSuccess}
/>
</div>
);
}
}
export default connect(null, actions )(PlaidAuthComponent);
从我的操作文件夹中的 index.js 文件中
export * from './transfer_actions';
我的 transfer_actions.js 文件
export const createTransferSource = (values, callback) => {
return function (dispatch){
axios({
method : 'POST',
url: `xxx/transfer_source.json`,
data: { values }
})
.then(response => {
dispatch({
type: CREATE_TRANSFER_SOURCE,
payload: response
});
})
.then(() => callback())
.catch( error => {
dispatch({
type: CREATE_TRANSFER_SOURCE_ERROR,
payload: error.response
});
});
};
};