34

im having this error when doing a named import from framer-motion module in reactjs. Obs: im not using webpack.

import { Fragment } from "react";

import classes from "./Hero.module.css";

import { motion } from "framer-motion";

import Header from "../header/Header";

export default function Hero() {
  return (
    <Fragment>
      <Header />
      <section className={classes.banner}>
        <img src="https://i.imgur.com/1arVXy2.jpg" />
        <motion.h1 className={classes.slogan}>Produtos de alta performance</motion.h1>
        <div className={classes['see-more']}>
          <span>Veja mais</span>
        </div>
      </section>
    </Fragment>
  );
}

enter image description here

Cláudio Vitor Dantas
  • 805
  • 4
  • 10
  • 17
  • 1
    You should provide more information and a way to reproduce your issue. Is that code the `index.mjs` file? Doesn't look like. Also, you should try to put the code inside code snippets, so that other users can copy it. – juliomrc Oct 29 '21 at 17:02
  • 1
    Welcome to Stack Overflow! Please take the [tour], have a look around, and read through the [help], in particular [*How do I ask a good question?*](/help/how-to-ask) Please post code, error messages, markup, and other textual information **as text**, not as a *picture* of text. Why: http://meta.stackoverflow.com/q/285551/157247 – T.J. Crowder Oct 29 '21 at 17:05
  • 5
    This is a bug in the new 5.x version. See this thread: https://github.com/framer/motion/issues/1307 – Ruslan Shashkov Nov 01 '21 at 07:35
  • 3
    Not really sure why this got closed. I added the full response from Framer to this duplicate question: https://stackoverflow.com/questions/69769360/error-importing-framer-motion-v5-in-react-with-create-react-app – Cadin Nov 04 '21 at 15:59
  • I solved it by upgrading react-scripts. https://github.com/doczjs/docz/issues/1686#issuecomment-999002953 – Micael Mota Apr 26 '22 at 16:28
  • 1
    Try This it worked for me Fixed this by changing >>> import to " import {AnimatePresence, motion} from "framer-motion/dist/framer-motion"; " – haroon kiani Dec 02 '22 at 23:40
  • change the way to import motion, from import { motion } from 'framer-motion'; to import { motion} from "framer-motion/dist/framer-motion"; – aldo ls Jan 31 '23 at 06:19

0 Answers0