When using with React 18, typescript will throw an error when a function is passed as a child, specifically to use the close callback. Although this worked previously in React 17, this now throws an error. I believe this is due to the removal of implicit children as props.
As a quick fix, augmenting the module in a declaration file will do the trick if you set skipLibCheck to true, but I'm not sure what other side effects this could produce.
EDIT: The proposed fix seem to already exist in the source code, but it's commented out:
Is there a reason it's commented out?
Version
v2.0.5
Issue
When using with React 18, typescript will throw an error when a function is passed as a child, specifically to use the
close
callback. Although this worked previously in React 17, this now throws an error. I believe this is due to the removal of implicit children as props.Test Case
https://codesandbox.io/s/reactjs-popup-issue-template-forked-8cn80o?file=/src/index.tsx
Proposed Fix
A simple addition of the function type under
in
types.d.ts
seemed to do the trick for me.As a quick fix, augmenting the module in a declaration file will do the trick if you set
skipLibCheck
to true, but I'm not sure what other side effects this could produce.EDIT: The proposed fix seem to already exist in the source code, but it's commented out: Is there a reason it's commented out?