Skip to content

bug(react): AskableInspector useEffect deps incomplete — inspector not re-created when options change #270

Closed

Description

@vamgan

Summary

In packages/react/src/AskableInspector.tsx, the useEffect that creates the inspector panel lists only specific known properties (position, highlight, promptOptionsKey) as dependencies. Any other property of AskableInspectorOptions being added or changed won't trigger a re-create.

Current code

useEffect(() => {
  const handle = createAskableInspector(ctx, inspectorOptions);
  return () => handle.destroy();
}, [ctx, inspectorOptions.position, inspectorOptions.highlight, promptOptionsKey]);
//  ^ incomplete — other inspectorOptions fields not listed

Impact

If AskableInspectorOptions grows new configurable fields (custom CSS, callbacks, etc.), they will silently be ignored after initial mount. Currently low impact, but fragile as the options type evolves.

Fix

Either spread all known deps explicitly, or use a stable serialized key:

const inspectorKey = JSON.stringify(inspectorOptions);
useEffect(() => {
  const handle = createAskableInspector(ctx, inspectorOptions);
  return () => handle.destroy();
}, [ctx, inspectorKey]);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: reactReact adapter workbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions