chenglou / react-motion

A spring that solves your animation problems.
MIT License
21.68k stars 1.15k forks source link

Uncaught TypeError: Cannot read property 'ReactCurrentOwner' of undefined #447

Open alburritos opened 7 years ago

alburritos commented 7 years ago

I'm new to React Motion, and spent all day yesterday trying to get what I need. However, I can't figure out what has caused this issue

Uncaught TypeError: Cannot read property 'ReactCurrentOwner' of undefined

I've been playing around with the demos and currently this is what I have. If this is not enough code, please let me know!

  getStyles() {
    const endValue = this.state;
    return [endValue];
  },

  render() {
    return (
      <TransitionMotion
        styles={ this.getStyles }
        willEnter={() => null}
        willLeave={() => null}>
        {ball =>
          <div className="demo1">
            <div
              key="demo1"
              className={`demo1-ball ball-0`}
              style={{
                WebkitTransform: `translate3d(${ball[0].x - 25}px, ${ball[0].y + 25}px, 0)`,
                transform: `translate3d(${ball[0].x - 28}px, ${ball[0].y - 54}px, 0)`,
              }} />
            )}
          </div>
        }
      </TransitionMotion>
    );
  },

What is causing the error?

nkbt commented 7 years ago

That is definitely not enough info/context. React version, component structure, etc. Please create Codepen/jsbin example that can reproduce the issue, otherwise I have no idea 🤷‍♂️

I reckon I've seen this kind of error somewhere on my projects, but don't remember all the details. Probably was related with incorrect exports somewhere or mapper function within react tree

msand commented 7 years ago

Try deleting your node_modules folder and run yarn or npm install again, then rerun your build process / file watcher.

This error might happen if two separate versions of react-dom are loaded, e.g., by oneself (index.js) and another dependency (react-apollo) on the server side when used for SSR. Are you trying to render react-motion on the server side?

dmr07 commented 7 years ago

+1 @msand solution doesn't work for me. Once all the packages are installed, I still get the same error.

luchillo17 commented 7 years ago

It happened to me as well, but i have no react-motion installed, it happened to me in latest react-native version 0.45.1.

Now to search an answer to my issue.

image

mistryhiren94 commented 7 years ago

@luchillo17 i'm also facing same problem.....

mistryhiren94 commented 7 years ago

please help

luchillo17 commented 7 years ago

@mistryhiren94 You facing it with react-motion installed or without it?

TimoRuetten commented 7 years ago

Facing same issue without react-motion.

luchillo17 commented 7 years ago

So seeing a few are getting the error without react-motion i would dare to say it's most likely an error in React Native or React, or maybe the mismatch of their versions (i just recently knew that React Native is made to be compatible with specific versions of React).

mistryhiren94 commented 7 years ago

@luchillo17 thanks

lidakis commented 7 years ago

I had exactly the same problem in two projects.

In the first project that I have, I updated jest to 20.0.4 and babel-jest to 20.0.3 and everything worked like a charm.

In the second I had to do, 1) Delete node_modules folder 2) npm install 3) npm update

cooperka commented 7 years ago

Make sure you're on the same version of all the related dependencies.

For example, I just got this issue after upgrading to react-native v0.45.1. I fixed it by installing react v16.0.0-alpha.12 and react-test-renderer v16.0.0-alpha.12 to match (you can find the correct version number in react-native's package.json).

sportsbench commented 6 years ago

Upping the version of react from react v16.0.0-alpha.6 to react v16.0.0-alpha.12 fixed this for me thanks @cooperka

pvn-nhat-nhan commented 6 years ago

https://github.com/react-community/create-react-native-app/blob/master/VERSIONS.md Like @cooperka said, we need match version. Please look above page to correct version

rwieruch commented 6 years ago

I ran into the problem when executing my Jest tests for the first time. I hadn't updated my package.json dependencies for a while (not using React 16), that's why I had to update them. I used npm-check-updates as a neat node package for it:

npm i -g npm-check-updates
npm-check-updates -u
npm install
oliverwatkins commented 6 years ago

For me the problem was that i was using React 15.x.x. I updated to 16 and now I don't get this problem with Jest anymore

ifyio commented 6 years ago

I got this issue because I did not include react as a dependency

RobertApelian commented 6 years ago

I also had the problem with React 15 and jest, but updating to 16 was not an option. Downgrading react-test-renderer to ^15 worked though.

davidcalhoun commented 6 years ago

@RobertApelian Worked for me! Using react 15.5.4 and react-test-renderer 15.6.2 now.

Olivr3 commented 6 years ago

@RobertApelian Worked for me! Thank you.

yagoazedias commented 6 years ago

Updated to react 16.3.2 worked for me too

Snnapy commented 6 years ago

For me the problem was that I had react and react-dom different versions. Updating those fixed the problem.

chai-yinghua commented 6 years ago

@Snnapy resolve the problem after match both version, thank you.

Vimallakzz commented 5 years ago

React and React dom version might be mismatch.. Example... React 15.4.2 needs version less 16 .x React dom