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

Feedback for “<MagicMotion />”Invalid prop style supplied to React.Fragment. React.Fragment can only have key and children props #21

Open
dlrodev92 opened this issue Dec 8, 2023 · 4 comments

Comments

@dlrodev92
Copy link

I can't figure out this.

@Etesam913
Copy link
Owner

Can you provide the code that you wrote which led to this error? This would be helpful for me in figuring out why this is happening.

@Rangel7y
Copy link

Me too received this warnings:
"Warning: Invalid prop style supplied to React.Fragment. React.Fragment can only have key and children props.
at MotionComponent..."

"Warning: Invalid attribute ref supplied to React.Fragment.
at MotionComponent..."

My code at the moment:

image

@Etesam913
Copy link
Owner

Etesam913 commented Jan 20, 2024

So, this error appears when there is a fragment as a child of the MagicMotion.

For example, this warning will show below:

import "./App.css";
import { MagicMotion } from "react-magic-motion";
import { useState } from "react";

export default function App() {
  const [shouldShow, setShouldShow] = useState(false);
  return (
    <main
      style={{
        padding: "0.75rem 1rem 0",
        display: "flex",
        flexDirection: "column",
      }}
    >
      <MagicMotion>
        <>
          <div>item 1</div>
          <div>item 2</div>
        </>
      </MagicMotion>
    </main>
  );
}

The solution here is to change the fragment into a div or some other tag.

For example, this is a solution

<MagicMotion>
  <div>
    <div>item 1</div>
    <div>item 2</div>
  </div>
</MagicMotion>

I would assume that somewhere in your components that are children of a MagicMotion, you are using empty brackets <> </>

@dlrodev92
Copy link
Author

thanks, that works for me now. Sorry for responding this late.

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

No branches or pull requests

3 participants