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

React 19 #2667

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

React 19 #2667

wants to merge 5 commits into from

Conversation

mattgperry
Copy link
Collaborator

@mattgperry mattgperry commented May 16, 2024

This PR upgrades React to v19.

Fixes #2668

Current release: 12.0.0-alpha.1

Because Framer will be on React 18 perhaps for a while, the current plan is to keep this PR open, release as 12.0.0, keep main for 11.x releases and rebase them into 12.x for the time being.

TODO

  • Upgrade React
  • Build success
  • Fix types
  • Fix SSR tests
  • Fix unit tests
  • Fix e2e tests
  • Test backwards compatibility with 18.x (tested - because of changes to types it doesn't look like it)
  • Merge in Upgrade React Three Fiber 9 #2699 and restore 3d tests to CI
  • Upgrade to React 19 final on release
  • Release 12.0.0

@eps1lon
Copy link

eps1lon commented May 22, 2024

For types, I'd recommend starting with npx types-react-codemod preset-19 ~/path-to-framer-motion-typescript-files. DefinitelyTyped/DefinitelyTyped#69022 has the full changelog.

yarn.lock Outdated
@@ -3703,6 +3712,15 @@ __metadata:
languageName: node
linkType: hard

"@types/react@npm:types-react@beta":
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use resolutions to enforce a single version of @types/react and @types/react-dom as suggested in the upgrade guide

Multiple versions of @types/react is not supported just like multiple versions of react are not supported.

@mattgperry
Copy link
Collaborator Author

@eps1lon I did try that but it didn't make any changes. Luckily I think I'm making headway with the types now.

@eps1lon
Copy link

eps1lon commented May 22, 2024

@eps1lon I did try that but it didn't make any changes.

I just tried it in a fresh clone and it made changes to 25 files:

$ npx types-react-codemod@latest preset-19 .
Processing 779 files... 
Spawning 10 workers...
Results: 
0 errors
753 unmodified
1 skipped
25 ok
Time elapsed: 6.403seconds 

@mattgperry
Copy link
Collaborator Author

@eps1lon I did try that but it didn't make any changes.

I just tried it in a fresh clone and it made changes to 25 files:

$ npx types-react-codemod@latest preset-19 .
Processing 779 files... 
Spawning 10 workers...
Results: 
0 errors
753 unmodified
1 skipped
25 ok
Time elapsed: 6.403seconds 

Ah interesting, I must have done it wrong. I’ll give it another shot, thanks.

@mattgperry mattgperry changed the base branch from main to feature/vite June 5, 2024 12:37
@izakfilmalter
Copy link

So hype for this.

Base automatically changed from feature/vite to main June 12, 2024 11:10
@mattgperry mattgperry force-pushed the upgrade/react-19 branch 3 times, most recently from 215aa43 to 7570162 Compare June 13, 2024 09:37
@steve-marmalade
Copy link

Thanks for pushing on this. I'm very happy to report that [email protected] is working well in my project running the latest NextJS canary and the latest react-19 RC.

@steve-marmalade
Copy link

Hi @mattgperry , just curious, does:

mean that you've already made significant progress on Framer Motion 3d compatibility with React 19?

I ask because I remember seeing the following warning in the docs, so it was a pleasant surprise.

Warning: Framer Motion 3D is only compatible with React 18, with no timeline for React 19 compatibility.

@mattgperry mattgperry changed the base branch from main to feature/react-19-code June 19, 2024 09:18
@mattgperry mattgperry changed the base branch from feature/react-19-code to main June 19, 2024 09:30
@eps1lon eps1lon mentioned this pull request Jul 1, 2024
22 tasks
@mattgperry
Copy link
Collaborator Author

mattgperry commented Jul 10, 2024

@steve-marmalade Yeah I think 3D should be working now but that will rely on the deps defined in the package.json. Due to its low usage if it takes too much time to upgrade it could be that we have to leave it for a while but luckily doesn't seem to be the case for now.

@krachtstefan
Copy link

Thanks for pushing on this. I'm very happy to report that [email protected] is working well in my project running the latest NextJS canary and the latest react-19 RC.

@steve-marmalade I'm also the latest NextJS canary (15.0.0-rc.0) but have some TypeScript problems. Did you change anything else after switching to [email protected]? The API did not change, right? My animation works but TypeScript complains with:

JSX element type 'motion.div' does not have any construct or call signatures.

and

'motion.div' cannot be used as a JSX component.
  Its type 'ForwardRefComponent<HTMLElementType, HTMLMotionProps<HTMLElementType>> | undefined' is not a valid JSX element type.
    Type 'undefined' is not assignable to type 'ElementType'.

I basically just use a very basic <motion.div ...

@Apezdr
Copy link

Apezdr commented Jul 15, 2024

Getting a weird bug where the opacity isn't transitioning when I refresh the page (but fixes itself if I hard refresh shift-refresh). Using NextJS. Not sure how to solve for it because this issue was introduced in upgrading the packages below. I am using framer motion in my template for the route, also using the /src directory with a master layout.js that doesn't use any framer motion in it.

"next": "^15.0.0-rc.0",
"react": "^19.0.0-rc-df5f2736-20240712",
"react-dom": "^19.0.0-rc-df5f2736-20240712",
"framer-motion": "^12.0.0-alpha.0",

// src\app\template.js
'use client'
import { motion } from 'framer-motion'

const variants = {
  hidden: { opacity: 0, x: 0, y: 0 },
  enter: { opacity: 1, x: 0, y: 0 },
}

export default function Template({ children }) {
  return (
    <motion.main
      variants={variants}
      initial="hidden"
      exit="hidden"
      animate="enter"
      transition={{ type: 'linear', duration: 0.25 }}
      key="LandingPage"
    >
      {children}
    </motion.main>
  )
}

@lucascurti
Copy link

Getting a weird bug where the opacity isn't transitioning when I refresh the page (but fixes itself if I hard refresh shift-refresh). Using NextJS. Not sure how to solve for it because this issue was introduced in upgrading the packages below. I am using framer motion in my template for the route, also using the /src directory with a master layout.js that doesn't use any framer motion in it.

@Apezdr I'm getting the same behavior. This PR that might address the issue was just merged (more info here). It will hopefully be fixed once these changes are merged in the v12 alpha version.

@tyteen4a03
Copy link

Any chance we can get a alpha-1 backporting fixes since alpha-0 release?

@mattgperry
Copy link
Collaborator Author

@tyteen4a03 You can upgrade to 12.0.0-alpha.1 now, this contains all the latest releases!

@lucascurti
Copy link

Getting a weird bug where the opacity isn't transitioning when I refresh the page (but fixes itself if I hard refresh shift-refresh). Using NextJS. Not sure how to solve for it because this issue was introduced in upgrading the packages below. I am using framer motion in my template for the route, also using the /src directory with a master layout.js that doesn't use any framer motion in it.

@Apezdr In case you want to give it a try, I've tested v12.0.0-alpha.1 and this is fixed for me

@jeffijoe
Copy link

Thanks @mattgperry, that seems to fix all the issues I've been having, except for one: popLayout doesn't seem to have any effect. Are there still any gotchas to watch out for? I remember reading that opacity could be a problem but I tried removing opacity styles and still see the same issue in that the space that the exiting element occupied is not made available until the animation is done.

@bdrtsky
Copy link

bdrtsky commented Oct 11, 2024

useAnimationControls is not working in Framer Motion 12?

@mattgperry
Copy link
Collaborator Author

Btw I'm attempting to upgrade to RC1 now. Not the smoothest process 😅 but hopefully new alpha today or Tuesday.

Fixing dep

React 19

Upgrade React 19

Upgrading React 19

fixing gitignore

Updating import

Fixing 3D types

Fixing conflict

Fixing conflicts

Fixing willChange

v12.0.0-alpha.1

Updating to latest RC

Latest

Fixing test
@imjeehoo
Copy link

Maybe you need to update Current release to 12.0.0-alpha.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Incompatible with React 19