The useSetPartialRowCallback hook returns a parameterized callback that can be used to sets partial data of a single Row in the Store, leaving other Cell values unaffected.

  tableId: string,
  rowId: string,
  getPartialRow: (parameter: Parameter, store: Store) => Row,
  getPartialRowDeps?: DependencyList,
  storeOrStoreId?: StoreOrStoreId,
  then?: (store: Store, partialRow: Row) => void,
  thenDeps?: DependencyList,
): ParameterizedCallback<Parameter>

The Id of the Table in the Store.


The Id of the Row in the Table to set.

getPartialRow(parameter: Parameter, store: Store) => Row

A function which returns the partial Row object that will be used to update the Store, based on the parameter the callback will receive (and which is most likely a DOM event).


An optional array of dependencies for the getRow function, which, if any change, result in the regeneration of the callback. This parameter defaults to an empty array.


The Store to be updated: omit for the default context Store, provide an Id for a named context Store, or provide an explicit reference.

then?(store: Store, partialRow: Row) => void

A function which is called after the mutation, with a reference to the Store and the Row used in the update.


An optional array of dependencies for the then function, which, if any change, result in the regeneration of the callback. This parameter defaults to an empty array.


A parameterized callback for subsequent use.

This hook is useful, for example, when creating an event handler that will mutate the data in Store. In this case, the parameter will likely be the event, so that you can use data from it as part of the mutation.

The third parameter is a function which will produce the partial Row object that will then be used to update the Store in the callback.

If that function has any other dependencies, the changing of which should also cause the callback to be recreated, you can provide them in an array in the optional fourth parameter, just as you would for any React hook with dependencies.

For convenience, you can optionally provide a then function (with its own set of dependencies) which will be called just after the Store has been updated. This is a useful place to call the addCheckpoint method, for example, if you wish to add the mutation to your application's undo stack.

The Store to which the callback will make the mutation (indicated by the hook's storeOrStoreId parameter) is always automatically used as a hook dependency for the callback.


This example uses the useSetPartialRowCallback hook to create an event handler which updates the Store when the span element is clicked.

const store = createStore().setRow('pets', 'nemo', {species: 'fish'});
const App = () => {
  const handleClick = useSetPartialRowCallback(
    (e) => ({bubbles: e.bubbles}),
    (store, partialRow) =>
      console.log(`Updated: ${JSON.stringify(partialRow)}`),
  return (
    <span id="span" onClick={handleClick}>
      {JSON.stringify(useRow('pets', 'nemo', store))}

const app = document.createElement('div');
ReactDOM.render(<App />, app);
const span = app.querySelector('span');
// -> '{"species":"fish"}'

// User clicks the <span> element:
// -> span MouseEvent('click', {bubbles: true})
// -> 'Updated: {"bubbles":true}'

// -> '{"species":"fish","bubbles":true}'