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

Removing ability to start animations within the render function #1870

Merged
merged 2 commits into from Jan 6, 2023

Conversation

mattgperry
Copy link
Collaborator

In the early days of Framer, back before concurrent rendering, people would write code like this

function Component() {
  const controls = useAnimationControls()

  controls.start({ x: 100 })
  
  return <motion.div animate={controls} />
}

Because it usually worked (even though it was always a poor idea). However now with concurrent rendering, this is likely to break as components can be rendered multiple times, or prospectively with props that don't end up committed to the DOM.

This PR changes the behaviour here so that rather than obfuscating this by saving up pending animations on the initial render, we throw an error.

Copy link
Collaborator

@adamseckel adamseckel left a comment

Choose a reason for hiding this comment

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

👍

@mattgperry mattgperry added the automerge Land this PR label Jan 6, 2023
@mergetron mergetron bot merged commit 3c08ec2 into main Jan 6, 2023
@mergetron mergetron bot deleted the fix/error-unmounted-start branch January 6, 2023 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Land this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants