flexlayout-react
    Preparing search index...

    Function useUndo

    • React hook that encapsulates undo/redo for a FlexLayout Model. It owns the model state, records an undo snapshot before each model mutation (collapsing an entire drag gesture into a single step), and replaces the model on undo/redo via Model.fromJson so mounted tab content is preserved. The model is passed to the Layout component from the returned model field.

      const { model, setModel, undo, redo, canUndo, canRedo, undoCount, redoCount } = useUndo(initialModel);

      <Layout model={model} factory={factory} />
      <button onClick={undo} disabled={!canUndo}>Undo ({undoCount})</button>
      <button onClick={redo} disabled={!canRedo}>Redo ({redoCount})</button>

      Parameters

      • OptionalinitialModel: Model | (() => Model | null) | null

        the initial model (or null if the model is loaded asynchronously), or a function that lazily returns it (evaluated once, like a useState initializer)

      • Optionaloptions: IUndoOptions

        optional configuration

      Returns IUseUndoResult