我尝试将套接字连接传递给我的道具。
这里是我的代码:
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import * as actions from '../redux/actions.js'
import Main from './main.jsx';
let socket = io(`http://localhost:8090`);
function mapStateToProps(state) {
return {
MyState
}
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators(actions, dispatch),
socket: bindActionCreators({socket}, dispatch)
}
}
const App = connect(mapStateToProps, mapDispatchToProps)(Main);
export default App;
它不起作用。我的套接字对象在我的道具中是空的。我认为它期望像行动这样的功能。如何将socket对象传递给我的道具?
感谢您的回答