Skip to content

[v9] Uncaught (in promise) TypeError: Cannot read property 'asyncId' of undefined #955

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

Closed
brotzky opened this issue Apr 9, 2020 · 9 comments
Labels
kind: bug Something isn't working
Milestone

Comments

@brotzky
Copy link

brotzky commented Apr 9, 2020

Whenever my useTransition hook uses async await next it throws an error of

Uncaught (in promise) TypeError: Cannot read property 'asyncId' of undefined
    at _callee6$ (runAsync.ts:81)
...

Using Yarn Workspaces with react-spring version:
"react-spring": "9.0.0-canary.809.5.f01ecc2",


This is my code, based off https://github.com/react-spring/react-spring-examples/blob/pull-750/demos/hooks/notification-hub/index.js

const [refMap] = useState(() => new WeakMap())
const config = { tension: 125, friction: 20, precision: 0.1 }

const transitions = useTransition(blocks, {
    initial: null,
    from: { height: 0, opacity: 0, overflow: 'hidden' },
    enter: item => async next => {
      await next({ height: refMap.get(item).offsetHeight, opacity: 1, overflow: 'hidden', config })
    },
    leave: { height: 0, opacity: 0, overflow: 'hidden', config },
    key: block => block.id,
})

 return (
   <div>
      {transitions((style, block) => {
        return (
          <animated.div style={style}>
              <div ref={ref => ref && refMap.set(block, ref)>
                  <Block block={block} />
              </div>
          </animated.div>
        )
     })}
  </div>
)

Changing the transition to

const transitions = useTransition(blocks, {
    initial: null,
    from: { height: 0, opacity: 0, overflow: 'hidden' },
    enter: { height: 100, opacity: 1, overflow: 'hidden', config },
    leave: { height: 0, opacity: 0, overflow: 'hidden', config },
    key: block => block.id,
})

resolves the issue but I don't get access to the ref/dynamic height of the element within the transition.

Any ideas if this is a react spring issue or somewhere else? The transition worked in v8. I upgraded because I wanted to be able properly get access to the updated state within item (#949).

could be related to: #920

@aleclarson
Copy link
Contributor

You can find the latest canary here:
https://www.npmjs.com/package/react-spring?activeTab=versions

9.0.0-canary.808.17.55c5691 at the time of writing.

That should fix your issue. LMK if it doesn't. 👍

@brotzky
Copy link
Author

brotzky commented Apr 9, 2020

I did try that one, and also tried beta-34. I'll give it another shot with the one you mentioned and report back! 🤞

@brotzky
Copy link
Author

brotzky commented Apr 9, 2020

Same issue @aleclarson:

"react-spring": "9.0.0-canary.808.17.55c5691",

Screen Shot 2020-04-08 at 7 09 35 PM

@aleclarson
Copy link
Contributor

Lovely. I can get this fixed before the next canary. Do you have a minimal reproducible build?

@aleclarson aleclarson added the type: needs repro Needs minimal reproduction label Apr 9, 2020
@brotzky
Copy link
Author

brotzky commented Apr 9, 2020

❤️ Let me try to put one together for you. Thanks for all the help.

edit: can't reproduce from blank CRA template. Going to attempt to strip down our codebase enough to reproduce it.

@brotzky
Copy link
Author

brotzky commented Apr 9, 2020

@aleclarson here's a repro: https://github.com/brotzky/react-spring-repro-issue-955
let me know if you're able to reproduce it or have questions.

@aleclarson aleclarson reopened this Apr 12, 2020
@aleclarson aleclarson removed the type: needs repro Needs minimal reproduction label Apr 12, 2020
@aleclarson aleclarson added this to the v9.0.0 milestone Apr 17, 2020
@aleclarson
Copy link
Contributor

Just tested your repro on the latest code. Should be fixed in 9.0.0-canary.808.18 which I will try to release in a day or two. 👍

@aleclarson aleclarson added the kind: bug Something isn't working label Apr 17, 2020
@brotzky
Copy link
Author

brotzky commented Apr 17, 2020

Wow, amazing!! thanks so much @aleclarson. No rush -- take your time.

@aleclarson
Copy link
Contributor

Now available in v9.0.0-rc.2 #985

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants