Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add $$typeof brand back to ForwardRefComponent #2631

Merged

Conversation

jeremybanka
Copy link
Contributor

@jeremybanka jeremybanka commented Apr 18, 2024

The recent change to Framer's ForwardRefComponent type breaks compatibility with React.ForwardRefExoticComponent due to a missing property $$typeof, which lives on React.ExoticComponent.

This means that Framer's motion components won't be accepted in contexts calling for a standard ForwardRefExoticComponent. See below:

Working in framer-motion@11.1.3, but breaks in framer-motion@11.1.4

import * as React from "react"
import { motion } from "framer-motion"

function myComponentFactory<P>(component: React.ForwardRefExoticComponent<P>) {
  // implementation
}

myComponentFactory(motion.header) 
/*
❗ Property '$$typeof' is missing in type 'ForwardRefComponent<HTMLElement, HTMLMotionProps<"header">>'
*/

With this change, ForwardRefComponent's type behaves as normal, and can retain the JSX.Element return type while better supporting React's type implementation.

@jeremybanka
Copy link
Contributor Author

For reference, here is the CI run where this cropped up for me. https://github.com/jeremybanka/wayforge/actions/runs/8739979388/job/23982565561

@mergetron mergetron bot merged commit caaac5b into framer:main Apr 19, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants