message: scaffolder: memo methods in DryRunProvider
diff: @@ -20,6 +20,7 @@ import { JsonObject } from '@backstage/types';
  import React, {
  createContext,
  ReactNode,
  + useCallback,
  useContext,
  useMemo,
  useRef,
  @@ -64,10 +65,7 @@ export function DryRunProvider(props: DryRunProviderProps) {
  });
  const idRef = useRef(1);
  - const dryRun = useMemo(
  - () => ({
  - ...state,
  - selectResult: (id: number) => {
  + const selectResult = useCallback((id: number) => {
  setState(prevState => {
  const result = prevState.results.find(r => r.id === id);
  if (result === prevState.selectedResult) {
  @@ -78,8 +76,9 @@ export function DryRunProvider(props: DryRunProviderProps) {
  selectedResult: result,
  };
  });
  - },
  - deleteResult: (id: number) => {
  + }, []);
  +
  + const deleteResult = useCallback((id: number) => {
  setState(prevState => {
  const index = prevState.results.findIndex(r => r.id === id);
  if (index === -1) {
  @@ -95,8 +94,10 @@ export function DryRunProvider(props: DryRunProviderProps) {
  : prevState.selectedResult,
  };
  });
  - },
  - execute: async (options: DryRunOptions) => {
  + }, []);
  +
  + const execute = useCallback(
  + async (options: DryRunOptions) => {
  if (!scaffolderApi.dryRun) {
  throw new Error('Scaffolder API does not support dry-run');
  }
  @@ -123,8 +124,17 @@ export function DryRunProvider(props: DryRunProviderProps) {
  selectedResult: prevState.selectedResult ?? result,
  }));
  },
  + [scaffolderApi],
  + );
  +
  + const dryRun = useMemo(
  + () => ({
  + ...state,
  + selectResult,
  + deleteResult,
  + execute,
  }),
  - [scaffolderApi, state],
  + [state, selectResult, deleteResult, execute],
  );
  return (
  