Skip to content

Using withAccessToken causes error: Can't perform a React state update on a component that hasn't mounted yet #18002

@ksenousi

Description

@ksenousi

Description

The withAccessToken has worked fine previously however has started causing issues with react state and triggering the following error message Can't perform a React state update on a component that hasn't mounted yet. This indicates that you have a side-effect in your render function that asynchronously later calls tries to update the component. Move this work to useEffect instead.

Steps To Reproduce

  1. Wrap any component in the withAccessToken like so:
import { List } from "@raycast/api";
import { OAuthService, withAccessToken } from "@raycast/utils";

function Command() {
  return (
    <List>
      <List.Item title="Hello" />
    </List>
  );
}

const google = OAuthService.google({
  clientId: "", // redacted for privacy reasons
  scope: "https://www.googleapis.com/auth/userinfo.email",
});

export default withAccessToken(google)(Command);
  1. npm run dev
  2. Error should appear after running the command

Current Behaviour

Error message appears and inconsistent useState hooks behaviour with the List searchText prop.

Expected Behaviour

No error messages when running

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiIssues related to APIbugSomething isn't workingstatus: fixed in next releaseThe issue will be closed once next release is available

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions