Trying to upgrade from 8.0.27 -> 9.2.0 #1544
-
Really hunted around for examples, and the documentation seems pretty light, at least, it was very hard to find any transitional information from 8->9 or a record of what the API was like during 8. Anyways, I'm trying to wrap my head around this. const [, setX] = useSpring(() => ({
from: { x: 0 },
to: { x: 0 },
onFrame: (props: { x: number }) => {
if (containerRef.current) {
containerRef.current.scrollLeft = props.x;
}
},
})); and then later setX({
from: { x: scrollPosition },
to: { x: newX },
onFrame: (props: { x: number }) => {
if (containerRef.current) {
containerRef.current.scrollLeft = props.x;
}
},
reset: true,
config: { friction: 60, tension: 500, velocity: 20 },
}); From what I understand, Proposed change: setX.start({
from: { x: scrollPosition },
to: { x: newX },
onChange: (props: { x: number }) => {
if (containerRef.current) {
containerRef.current.scrollLeft = props.x;
}
},
reset: true,
config: { friction: 60, tension: 500, velocity: 20 },
}); results in
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I think your issue is how you're using In short, you might need to change: onChange: (props: { x: number }) => {
if (containerRef.current) {
containerRef.current.scrollLeft = props.x;
}
}, to: onChange: (result) => {
if (containerRef.current) {
containerRef.current.scrollLeft = result.value.x;
}
}, However, if you're still having issues, if you can make a CodeSandbox I can take a look 👍🏼 |
Beta Was this translation helpful? Give feedback.
I think your issue is how you're using
onChange
the first argument isn'tprops
, this was documented in the changelog here and also in theprops
section of the docs.In short, you might need to change:
to:
However, if you're still having issues, if you can make a CodeSandbox I can take a look 👍🏼