Skip to content

Commit

Permalink
fix(motion): replace deprecated method with the new helper
Browse files Browse the repository at this point in the history
  • Loading branch information
plouc committed Nov 16, 2020
1 parent 25aa18f commit 57b27d8
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions packages/bump/src/bump/Point.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
import React, { memo } from 'react'
import PropTypes from 'prop-types'
import { useSpring, animated } from 'react-spring'
import { useSpring, animated, to } from 'react-spring'
import { useMotionConfig } from '@nivo/core'

const pointStyle = { pointerEvents: 'none' }
Expand All @@ -30,7 +30,7 @@ const Point = ({ x, y, size, color, borderColor, borderWidth }) => {
<animated.circle
cx={animatedProps.x}
cy={animatedProps.y}
r={animatedProps.radius.interpolate(v => Math.max(v, 0))}
r={to(animatedProps.radius, v => Math.max(v, 0))}
fill={animatedProps.color}
strokeWidth={animatedProps.borderWidth}
stroke={borderColor}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/hooks/useAnimatedPath.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { interpolateString } from 'd3-interpolate'
import { useEffect, useMemo, useRef } from 'react'
import { useSpring, to } from 'react-spring'
import { useMotionConfig } from '../motion'
import { useSpring } from 'react-spring'

const usePrevious = value => {
const ref = useRef()
Expand All @@ -27,5 +27,5 @@ export const useAnimatedPath = path => {
immediate: !animate,
})

return value.interpolate(interpolator)
return to(value, interpolator)
}
4 changes: 2 additions & 2 deletions packages/radar/src/RadarGridLevels.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import React, { memo, useMemo } from 'react'
import PropTypes from 'prop-types'
import { lineRadial, curveLinearClosed } from 'd3-shape'
import { animated, useSpring } from 'react-spring'
import { animated, useSpring, to } from 'react-spring'
import { useTheme, useAnimatedPath, useMotionConfig } from '@nivo/core'

const RadarGridLevelCircular = memo(({ radius }) => {
Expand All @@ -25,7 +25,7 @@ const RadarGridLevelCircular = memo(({ radius }) => {
return (
<animated.circle
fill="none"
r={animatedProps.radius.interpolate(value => Math.max(value, 0))}
r={to(animatedProps.radius, value => Math.max(value, 0))}
{...theme.grid.line}
/>
)
Expand Down
6 changes: 3 additions & 3 deletions packages/sankey/src/SankeyNodesItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
import React, { memo, useCallback, useMemo } from 'react'
import PropTypes from 'prop-types'
import { useSpring, animated } from 'react-spring'
import { useSpring, animated, to } from 'react-spring'
import { useMotionConfig } from '@nivo/core'
import { BasicTooltip, useTooltip } from '@nivo/tooltip'

Expand Down Expand Up @@ -80,8 +80,8 @@ const SankeyNodesItem = ({
<animated.rect
x={animatedProps.x}
y={animatedProps.y}
width={animatedProps.width.interpolate(v => Math.max(v, 0))}
height={animatedProps.height.interpolate(v => Math.max(v, 0))}
width={to(animatedProps.width, v => Math.max(v, 0))}
height={to(animatedProps.height, v => Math.max(v, 0))}
fill={animatedProps.color}
fillOpacity={animatedProps.opacity}
strokeWidth={borderWidth}
Expand Down
6 changes: 3 additions & 3 deletions packages/treemap/src/TreeMapNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
import React, { memo } from 'react'
import PropTypes from 'prop-types'
import { animated } from 'react-spring'
import { animated, to } from 'react-spring'
import { useTheme } from '@nivo/core'

const TreeMapNode = ({
Expand All @@ -31,8 +31,8 @@ const TreeMapNode = ({
return (
<animated.g transform={animatedProps.transform}>
<animated.rect
width={animatedProps.width.interpolate(v => Math.max(v, 0))}
height={animatedProps.height.interpolate(v => Math.max(v, 0))}
width={to(animatedProps.width, v => Math.max(v, 0))}
height={to(animatedProps.height, v => Math.max(v, 0))}
fill={node.fill ? node.fill : animatedProps.color}
strokeWidth={borderWidth}
stroke={node.borderColor}
Expand Down

0 comments on commit 57b27d8

Please sign in to comment.