marmelab/react-admin · error · Error

InPlaceEditor requires notifyOnSuccess to be true when mutat

Error message

InPlaceEditor requires notifyOnSuccess to be true when mutationMode is undoable

What it means

In undoable mutationMode, the edit is applied optimistically and then announced; InPlaceEditor relies on notifyOnSuccess to show the success notification that supports the undo flow. If mutationMode is 'undoable' and notifyOnSuccess is falsy, the library throws because the undoable flow cannot work correctly.

Source

Thrown at packages/ra-ui-materialui/src/input/InPlaceEditor/InPlaceEditor.tsx:98

                size="small"
                margin="none"
                label={false}
                variant="standard"
                autoFocus
                helperText={false}
            />
        ) : null,
        showButtons,
        notifyOnSuccess,
    } = props;

    if (!source && !children && !editor) {
        throw new Error(
            'InPlaceEditor requires either a source prop or children or editor prop'
        );
    }
    if (mutationMode === 'undoable' && !notifyOnSuccess) {
        throw new Error(
            'InPlaceEditor requires notifyOnSuccess to be true when mutationMode is undoable'
        );
    }

    const submitButtonRef = useRef<HTMLButtonElement>(null);

    const [state, dispatch] = useReducer<
        (
            state: InPlaceEditorValue,
            action: InPlaceEditorAction
        ) => InPlaceEditorValue
    >(
        (_, action) => {
            switch (action.type) {
                case 'edit':
                    return { state: 'editing' };
                case 'save':
                    return { state: 'saving', values: action.values };

View on GitHub (pinned to 051f511bb0)

Solutions

  1. Set notifyOnSuccess={true} on the InPlaceEditor
  2. Or change mutationMode to "pessimistic" or "optimistic" if notifications are not wanted

Example fix

// before
<InPlaceEditor source="title" mutationMode="undoable" notifyOnSuccess={false} />
// after
<InPlaceEditor source="title" mutationMode="undoable" notifyOnSuccess />
Defensive patterns

Strategy: validation

Validate before calling

if (mutationMode === 'undoable' && !notifyOnSuccess) {
  throw new Error('undoable InPlaceEditor requires notifyOnSuccess');
}

Type guard

const validInPlaceEditorMutation = (
  p: Pick<InPlaceEditorProps, 'mutationMode' | 'notifyOnSuccess'>
): boolean => p.mutationMode !== 'undoable' || p.notifyOnSuccess === true;

Try / catch

try {
  render(<InPlaceEditor source="title" mutationMode="undoable" />);
} catch (e) {
  if (e.message.includes('notifyOnSuccess')) {
    console.error('Undoable mode needs notifications:', e.message);
  }
}

Prevention

When it happens

Trigger: <InPlaceEditor mutationMode="undoable" /> (the default in some contexts) rendered without notifyOnSuccess={true} or with notifyOnSuccess explicitly false.

Common situations: Setting mutationMode="undoable" for optimistic updates but disabling notifications, or copying an example that sets notifyOnSuccess={false} (valid for pessimistic/undoable-less modes) into an undoable setup.

Related errors


AI-assisted analysis of marmelab/react-admin@051f511bb0 (2026-08-30). Data as JSON: /api/errors/2287e29e31e34ae5. Report an issue: GitHub.