State reducer

You can pass a state reducer to modify internal state of SpreadSheet Grid. The reducer receives the current state and action and should always return the new state.


This is a handy feature to modify internal state. Internal state is powered by Immer

import { ACTION_TYPE, Actiontypes, initialState } from '@rowsncolumns/spreadsheet'
const stateReducer = (state, action) => {
switch (action.type) {
// Using immer
return produce(state, draft => {
draft.selectedSheet = state.sheets[0].id
// Using Spread operator
return {
selectedSheet: state.sheets[0].id
return state
return <SpreadSheet stateReducer={stateReducer} />

This is similar to how Downshift manages internal state.