-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Cannot read property 'push' of undefined #576
Comments
interpolation also triggers for upfront stuff like colors in the spring definition and so on. you could put a log in there so that when it happens you can trace it back to the component code. it's not terribly type safe atm and if by accident you put a NaN/null/undefined/true/false/etc into it you can blow it up, then the interpolator will choke on it. There's some value for sure that's getting in there that isn't the state you probably expect it to be. If you have made out the position where the weird data goes in i could help with looking for the cause. |
I was able to add a breakpoint and see the value of the variables: This is at this line: https://github.com/react-spring/react-spring/blob/3f3464d754a9dd51598ef442dab8bc5482f1b439/src/shared/stringInterpolation.ts#L47 The app stays minimized for a long time, then I open it, my redux-saga dispatches an action that will trigger the theme change (because of the day/night change) and this happens. It's weird that it stays broken (keeps throwing this) if I tap to change theme again after this. Only goes back to normal after I refresh the page. May be related to #380 since it's showing Stack trace
|
could you paste more code, where does the color come from, which spring is it, and which props are you feeding it. this stuff is normally the easiest to fix, if it is a problem in spring i'll find it. |
I've seen this bug as well. I haven't found a reliable way to repro yet. What I can say is that the person who reported the bug to me - said the crash happens after they wake their laptop up from being asleep. To me this would point to something related to time (i.e. a lot of time passing with no animations and then perhaps resuming or starting an animation after a long wait? Grabbin at straws here). I can share the component here, since it's pretty small: /* @flow */
import * as React from 'react';
import classNames from 'classnames';
import {Spring, animated} from 'react-spring/renderprops';
import styles from './AnimatedHalfPill.mod.css';
const SPRING_CONFIG = {
tension: 400,
friction: 30,
};
type AnimatedHalfPillProps = {|
hovered: boolean,
unread: boolean,
selected: boolean,
className?: ?string,
|};
class AnimatedHalfPill extends React.Component<AnimatedHalfPillProps> {
static defaultProps = {
selected: false,
hovered: false,
unread: false,
};
render() {
const {className, hovered, selected, unread} = this.props;
return (
<div className={classNames(className, styles.wrapper)}>
<Spring
native
config={SPRING_CONFIG}
immediate={process.env.NODE_ENV === 'development' ? false : !document.hasFocus()}
to={{
opacity: selected ? 1 : 0.6,
height: selected ? 40 : hovered ? 20 : 8,
transform: hovered || selected || unread ? `translate3d(0px, 0, 0)` : `translate3d(-4px,0,0)`,
}}>
{style => <animated.span className={styles.item} style={style} />}
</Spring>
</div>
);
}
}
export default AnimatedHalfPill; Pretty sure, based on the stack trace, that the issue is related to the |
I don't use translate so it's probably any spring animation. |
Yeah - I think it might be something related to string interpolation - since it's not an error for the numbered values. I have a theory that it could be related to me not using a |
@amadeus do you use javascript function generators ( I'm suspecting this is causing some issues in my app because it's transpilled to es5, not sure if related to this issue specifically yet (but it's one generator that dispatches a theme change in my app, so...). |
In the case of this particular component, there are no generators involved as parents to or as a result of triggering this animation. We don't use redux either. |
Ok, good news! I figured out an easy repro! It has to do with being in immediate mode and applying a few different spring updates asynchronously. See this codepen for an easy crash: https://codesandbox.io/s/qvn4noqo0w If you update |
Good work, let's see what this is all about ... |
Any update on this? I can try digging in myself, but would probably take me a bit to get situated. |
i think it could be solved. @aleclarson is this in the v9 branch already? |
Not sure. @amadeus Can you give it a try with the git clone https://github.com/react-spring/react-spring.git --branch v9 --depth 1
cd ./react-spring
yarn
yarn link
# In your repro directory:
yarn link react-spring |
I don't have much experience using yarn link - but it doesn't seem to work here because I am attempting to import I was able to work around by just replacing the built files in node_modules with the ones from that branch, however it doesn't appear that the bug is fixed. I tried porting the example to Doing a bit more digging, threw in some breakpoints and started looking at what was being evaluated, and I think I found the source of where the issue stems from - but I don't totally have the context for how to fix. to start with the animation goes through 2 states, and the animated values iteratate through 3 different values: Stage 1 (initial): In this demo - it appears that stage 2 sets fine with no issue. The crash occurs when attempting to set stage 3 (only while in immediate mode) - and i think there must be some sort of race condition where I added a breakpoint right before the crash, and walked back up the stack trace to where I think the issue starts: I don't really have a whole lot more context on how this is supposed to work, but hopefully this is helpful for you guys at identifying why it breaks. |
@amadeus So #632 fixes this bug, but (currently) only for hooks. Once I finish #561, the render-props API will get the same fixes as hooks. The current |
What's the timing on v9? Looks like I may have to disable immediate mode until then. |
ASAP. Working on revamping the TypeScript defs, then merging #561 into that. Hopefully today! |
I ran I made this webpack config change to make the new version work, in case its useful to anyone:
Thanks a lot for your hard work 👍 👍 |
You can use v9 like this now: Let us know how it goes: #642 |
Hey! For those, who cannot / don't want to use v9 beta, I made up with a workaround that works out.
Then you don't use Of course, again, it's a WORKAROUND :) |
Related: #468 (but I'm not using translate)
Looking at the stack trace seems to be coming from this line:
https://github.com/react-spring/react-spring/blob/e73385837e7a75ef64e82d17a28e7c86fb5c0e49/src/shared/interpolation.ts#L48
The only code I'm using interpolation is this: https://github.com/devhubapp/devhub/blob/d6f8854c42f1a236bbd73bfa5a96cb18c8b380d2/packages/components/src/components/common/AccordionView.tsx#L18-L53
This seems to be some edge case thing. My electron app was minimized the whole day and when I reopened it this happened.
(and the theme colors were all buggy, might be related to this or not. first time I saw this and at the same time I got the error report on bugsnag):
The text was updated successfully, but these errors were encountered: