const Map = compose(
withStateHandlers(() => ({
isOpen: false,
markerIndex: 0
}), {
onToggleOpen: ({ isOpen }) => (index) => ({
isOpen: true,
markerIndex: index
})
}),
withScriptjs,
withGoogleMap
)
我想在另一个类中调用onToggleOpen,反正有做吗?
答案 0 :(得分:0)
您可以将onToggleOpen
提取到函数中,并将其导出以在另一个文件中使用。
const onToggleOpen = ({ isOpen }) => index => ({
isOpen: true,
markerIndex: index
});
const Map = compose(
withStateHandlers(() => ({ isOpen: false, markerIndex: 0 }), {
onToggleOpen
}),
withScriptjs,
withGoogleMap
);
// ES6 module syntax
export { onToggleOpen };
// CJS syntax
modules.exports = { onToggleOpen };