question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parsing paths always results in error: undefined is not an object (evaluating 'p.curves[index].c1')

See original GitHub issue

Hello all,

Im trying to interpolate between two different SVG Paths. Im using the example code from the documentation but when I replace the SVG path string provided in the examples with any other SVG path I get the following error. The parser seems to have some sort of limitation i’m not aware of ? Its just a simple path of a home icon.

import React from 'react'
import { View } from 'react-native'
import Animated, {
    useSharedValue,
    useAnimatedProps,
    withTiming,
    Easing,
} from 'react-native-reanimated'
import Svg, { Path } from 'react-native-svg'

import { interpolatePath, parse } from 'react-native-redash'

const AnimatedPath = Animated.createAnimatedComponent(Path)

Animated.addWhitelistedNativeProps({
    stroke: true,
})

// THIS PATH GIVE CAUSES THE ERROR
const PATH1 = parse(
    'M 12 2.0996094 L 1 12 L 4 12 L 4 21 L 11 21 L 11 15 L 13 15 L 13 21 L 20 21 L 20 12 L 23 12 L 12 2.0996094 z M 12 4.7910156 L 18 10.191406 L 18 11 L 18 19 L 15 19 L 15 13 L 9 13 L 9 19 L 6 19 L 6 10.191406 L 12 4.7910156 z'
)

// THIS PATH PROVIDED BY THE DOCUMENTATION WORKS
const PATH2 = parse(
    'M150,0 C175,0 0,100 100,75 M150,200 200,225 200,225 C225,200 200,150 0,150  '
)
const HomeSVG = ({ color, size }) => {
    const progress = useSharedValue(0)

    const animatedProps = useAnimatedProps(() => {
        const d = interpolatePath(progress.value, [0, 1], [PATH1, PATH2])
        return { d }
    })

    return (
        <View
            onTouchStart={() => {
                progress.value = withTiming(progress.value ? 0 : 1, {
                    duration: 1000,
                    easing: Easing.inOut(Easing.cubic),
                })
            }}
        >
            <Svg width={size} height={size} viewBox="0 0 24 24">
                <AnimatedPath
                    stroke="black"
                    strokeWidth={1}
                    fill="blue"
                    fillRule="evenodd"
                    strokeLinecap="round"
                    strokeLinejoin="round"
                    animatedProps={animatedProps}
                />
            </Svg>
        </View>
    )
}

export default HomeSVG

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
wcandilloncommented, Aug 13, 2021

redash is not nearly as sophisticated than flubber to do path interpolations but thanks for pointing me to flubber, I will definitely take inspiration from it to make the interpolation more flexible.

0reactions
haibertcommented, Aug 13, 2021

Thank you William! Also you could check out interpolatePath from d3-interpolate-path I think that was is a good one as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - React Native - TypeError: undefined is not an object ...
I am trying to recreate a simple React-Native MERN, todo application with a User register and login interface connecting to a Node and...
Read more >
react-native-redash - Bountysource
It seems like some function have changed place and are no longer found. ... Parsing paths always results in error: undefined is not...
Read more >
ajax call: "undefined is not an object (evaluating... - ServiceNow
I had a user complaining they are not able to use a certain page while using Safari on MacOS/Sierra which utilizes an Ajax...
Read more >
Error : “undefined is not an object (evaluating 'ky.post
Maybe your host is using a performance plugin, or some sort of web-standards-enforcing solution that adds types to script tags before we parse...
Read more >
Error "Undefined is not an object (evaluating 'e.default')"
Hello @Pongsakorn.P,. I found only one other forum post related to this issue and according to the recommendation there, your best chance at ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found