framer / motion

Open source, production-ready animation and gesture library for React
https://framer.com/motion
MIT License
22.56k stars 748 forks source link

fix typescript type for AnimatePresence component #1507

Closed anark closed 2 years ago

anark commented 2 years ago

After upgrading my React app to version 18 and upgrading @types/react to v18 I was getting errors when using the AnimatePresence component

Type '{ children: false | Element | undefined; initial: false; }' is not assignable to type 'IntrinsicAttributes & AnimatePresenceProps'.
  Property 'children' does not exist on type 'IntrinsicAttributes & AnimatePresenceProps'.

<AnimatePresence initial={false}>

This should fix the issue.

adhip94 commented 2 years ago

Can we get this merged? Related to #1509

filiptammergard commented 2 years ago

Ship it! 🚢

NuroDev commented 2 years ago

LGTM. Let's get this fix out 🚀

Liinkiing commented 2 years ago

You should also add it to the <LayoutGroup /> component IMO, I've searched accross the codebase, and these are the two components (<AnimatePresence/> and <LayoutGroup />) that should be affected by the changes of the types

https://github.com/framer/motion/blob/3d772790ed25b2dbe11a4a9a0c995a2e51fd3e04/packages/framer-motion/src/components/LayoutGroup/index.tsx#L27

anark commented 2 years ago

Thanks @Liinkiing , I've added that type change as well

Moinax commented 2 years ago

Hi @anark ,

When do you plan a release with this fix ?

Kind regards,

anark commented 2 years ago

Hi @anark ,

When do you plan a release with this fix ?

Kind regards,

I'm not an admin of this repo. It is up to them if/when the accept this fix and release

sachaw commented 2 years ago

@mattgperry could you please review this. It's a major blocker for me and several others. Thanks.

Liinkiing commented 2 years ago

@mattgperry could you please review this. It's a major blocker for me and several others. Thanks.

In the meantime, you could add a @ts-expect-error, it should be non blocking as it is just a TS issue, and you don't have to patch the package, so the ts-expect-error should to the trick

mattgperry commented 2 years ago

Great PR, thanks for jumping in!

sachaw commented 2 years ago

Also facing this issue with the AnimateSharedLayout Component

mattgperry commented 2 years ago

@sachaw AnimateSharedLayout has been deprecated since 5 https://www.framer.com/docs/guide-upgrade/#%23shared-layout-animations