Forward Dispatch Actions
1. Use forwardTo to add a dispatch function to your component
forwardTo to add a dispatch function to your component// component
import {KeplerGl} from '@kepler.gl/components';
import {connect} from 'react-redux';
// import action and forward dispatcher
import {toggleFullScreen, forwardTo} from '@kepler.gl/actions';
const MapContainer = props => (
<div>
<button onClick={() => props.keplerGlDispatch(toggleFullScreen())}/>
<KeplerGl
id="foo"
/>
</div>
)
const mapStateToProps = state => state
const mapDispatchToProps = (dispatch, props) => ({
dispatch,
keplerGlDispatch: forwardTo(‘foo’, dispatch)
});
export default connect(
mapStateToProps,
mapDispatchToProps
)(MapContainer);Last updated
Was this helpful?