Skip to content

typescript declaration of act should match React 16.9.x #436

Closed
@davidje13

Description

@davidje13

Since 16.9.0 was released with a fix for facebook/react#14769, act returns a Promise (and optionally takes in a Promise).

This line should be updated to allow this, or better yet, it should forward the type typeof act from @types/react-dom (see here, though I'm not sure if that's 100% correct since I think it is now allowed to pass in a promise).

Right now the workaround is to import act directly from react-dom (since act here is just a pass-through), or to define:

function asyncAct(fn: () => Promise<any> | void): Promise<void> {
  return act(fn) as any as Promise<void>;
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions