@joint/react
    Preparing search index...

    Function usePaper

    usePaper()

    • Access the JointJS paper (dia.Paper) instance for the surrounding <Paper>, a specific paper by id, or the default paper. Use it to drive the paper imperatively, scale, fit content, or wake it up, from anywhere under a GraphProvider.

      The returned object is referentially stable for a given resolved paper; its paper is null until the <Paper> view has mounted, so guard calls with paper?..

      Parameters

      • OptionalpaperId: string

        An explicit paper id, or omitted for the context/default paper.

      Returns PaperApi

      The PaperApi: the resolved paper (or null) plus wakeUp, freeze, and unfreeze actions.

      Result of usePaper, the paper instance and imperative actions.

      import { GraphProvider, Paper, usePaper } from '@joint/react';

      function FitButton() {
      const { paper } = usePaper();
      // `paper` is null until the <Paper> view has mounted.
      return <button onClick={() => paper?.transformToFitContent({ padding: 20 })}>Fit</button>;
      }

      function App() {
      return (
      <GraphProvider>
      <Paper />
      <FitButton />
      </GraphProvider>
      );
      }