Reducers is a redux-connected component that utilizes redux to manage its state. The basic implementation of reducer is simple. However, to make the most of it, it's recommended to have basic knowledge on:

It is immportant to understand the relationship between reducer, instance reducer and subreducer. reducer is the root reducer that combines multiple instance reducer, which manages the state of each individual component. The instance reducer is consists of 4 subreducers, each manages an independent part of the state.

KeplerGl Reducer

To connect components to your Redux app you'll need the following pieces from the package:

  • Redux Reducer: keplerGlReducer imported from

  • React Component: KeplerGl imported from

These are the only 2 pieces you need to get up and running in your app. When you mount reducer in your app reducer (with combineReducers), it will then managers ALL KeplerGl component instances that you add to your app. Each instance state is stored in a instance reduccer.

For instance, if you have 2 components in your App:

import KeplerGl from '';

const MapApp = () => (
    <KeplerGl id="foo"/>
    <KeplerGl id="bar"/>

Your redux state will be:

state = {
  keplerGl: {
    foo: {},
    bar: {}
  // ... other app state
  app: {}

Instance Reducer

Each component state is stored in a instance reduccer. A instance reducer has 4 subreducers. visState, mapState, mapStyle and uiState. Each of them managers a piece of state that is mostly self contained.

  • visState - Manages all data and visualization related state, including datasets, layers, filters and interaction configs. Some of the key updaters are updateVisDataUpdater, layerConfigChangeUpdater, setFilterUpdater, interactionConfigChangeUpdater.

  • mapState - Manages base map behavior including the viewport, drag rotate and toggle split maps. Key updates are updateMapUpdater, toggleSplitMapUpdater and togglePerspectiveUpdater.

  • mapStyle - Managers base map style, including setting base map style, toggling base map layers and adding custom base map style.

  • uiState - Managers all UI component transition state, including open / close side panel, current displayed panel etc. Note, ui state reducer is the only reducer that’s not saved in schema.


The subreducers - visState, mapState, mapStyle and uiState - are assembled by a list of action handlers, each handler mapped to a state transition function named xxUpdater. For instance, here is a snippet of the map state reducer in

/* Action Handlers */
const actionHandler = {

User can import a specific action handler in their root reducer and use it to directly modify’s state (without dispathcing a action). This will give user the full control over’s component state.

Here is an example how you can listen to an app action QUERY_SUCCESS and call updateVisDataUpdater to load data into

import keplerGlReducer, {visStateUpdaters} from '';

// Root Reducer
const reducers = combineReducers({
 keplerGl: keplerGlReducer,

 app: appReducer

const composedReducer = (state, action) => {
 switch (action.type) {
   case 'QUERY_SUCCESS':
     return {
       keplerGl: {

         // 'map' is the id of the keplerGl instance
         map: {
            visState: visStateUpdaters.updateVisDataUpdater(
              // you have to pass the subreducer state that the updater is associated with
              {datasets: action.payload}
 return reducers(state, action);

export default composedReducer;

Last updated