Skip to content
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

TypeError: Cannot read property 'slice' of undefined #112

Open
seelentov opened this issue Sep 7, 2024 · 1 comment
Open

TypeError: Cannot read property 'slice' of undefined #112

seelentov opened this issue Sep 7, 2024 · 1 comment

Comments

@seelentov
Copy link

seelentov commented Sep 7, 2024

export default function CurrencyScreen({ navigation, route }: CurrencyScreenProps) {

    const { id } = route.params

    const [dates, setDates] = useState<IValuteShowRequest>({
        start_date: convertDateToString(
            new Date(new Date().setDate(new Date().getDate() - 10))
        ),
        end_date: convertDateToString(new Date())
    })

    const { data, isLoading, error } = useGetValuteQuery({
        id,
        body: dates
    });

    const preparedData = data?.data

    const points = preparedData?.positions.map(position => {
        return {
            value: position.value,
            date: parseDateFromString(position.date)
        }
    })

    // const switchDate = (pos: 'start_date' | "end_date", date: Date) => {
    //     setDates(prev => { return { ...prev, [pos]: convertDateToString(date) } })
    // }

    if (isLoading) {
        return <Loading />
    }

    if (error) {
        return <Error />
    }

    return (
        <View style={baseStyles.wrapper}>
            <ScrollView style={baseStyles.scrollView}>
                {points && <LineGraph color={Colors.blue500} animated={true} points={points} />}
            </ScrollView>
        </View>
    );
}
ERROR  TypeError: Cannot read property 'slice' of undefined

This error is located at:
    in AnimatedLineGraph (created by LineGraphImpl)
    in LineGraphImpl (created by CurrencyScreen)
    in RCTView (created by View)
    in View (created by ScrollView)
    in RCTScrollView (created by ScrollView)
    in ScrollView (created by ScrollView)
    in ScrollView (created by CurrencyScreen)
    in RCTView (created by View)
    in View (created by CurrencyScreen)
    in CurrencyScreen (created by SceneView)
    in StaticContainer
    in EnsureSingleNavigator (created by SceneView)
    in SceneView (created by SceneView)
    in RCTView (created by View)
    in View (created by DebugContainer)
    in DebugContainer (created by MaybeNestedStack)
    in MaybeNestedStack (created by SceneView)
    in RCTView (created by View)
    in View (created by SceneView)
    in RNSScreen (created by Animated(Anonymous))
    in Animated(Anonymous) (created by InnerScreen)
    in Suspender (created by Freeze)
    in Suspense (created by Freeze)
    in Freeze (created by DelayedFreeze)
    in DelayedFreeze (created by InnerScreen)
    in InnerScreen (created by Screen)
    in Screen (created by SceneView)
    in SceneView (created by NativeStackViewInner)
    in Suspender (created by Freeze)
    in Suspense (created by Freeze)
    in Freeze (created by DelayedFreeze)
    in DelayedFreeze (created by ScreenStack)
    in RNSScreenStack (created by ScreenStack)
    in ScreenStack (created by NativeStackViewInner)
    in NativeStackViewInner (created by NativeStackView)
    in RCTView (created by View)
    in View (created by SafeAreaProviderCompat)
    in SafeAreaProviderCompat (created by NativeStackView)
    in NativeStackView (created by NativeStackNavigator)
    in PreventRemoveProvider (created by NavigationContent)
    in NavigationContent
    in Unknown (created by NativeStackNavigator)
    in NativeStackNavigator (created by Router)
    in Router (created by App)
    in AuthProvider (created by App)
    in NotifProvider (created by App)
    in EnsureSingleNavigator
    in BaseNavigationContainer
    in ThemeProvider
    in NavigationContainerInner (created by App)
    in RCTView (created by View)
    in View (created by App)
    in ThemeProvider (created by PaperProvider)
    in RCTView (created by View)
    in View (created by Portal.Host)
    in Portal.Host (created by PaperProvider)
    in RNCSafeAreaProvider (created by SafeAreaProvider)
    in SafeAreaProvider (created by SafeAreaInsetsContext)
    in SafeAreaProviderCompat (created by PaperProvider)
    in PaperProvider (created by App)
    in Provider (created by App)
    in App (created by withDevTools(App))
    in withDevTools(App)
    in RCTView (created by View)
    in View (created by AppContainer)
    in RCTView (created by View)
    in View (created by AppContainer)
    in AppContainer
    in main(RootComponent), js engine: hermes

@seelentov
Copy link
Author

const points = [{"date": 2024-08-28T19:00:00.000Z, "value": 897.2629999999999}, {"date": 2024-08-29T19:00:00.000Z, "value": 896.959}, {"date": 2024-08-30T19:00:00.000Z, "value": 891.172}, {"date": 2024-09-02T19:00:00.000Z, "value": 880.2819999999999}, {"date": 2024-09-03T19:00:00.000Z, "value": 863.4789999999999}, {"date": 2024-09-04T19:00:00.000Z, "value": 862.935}, {"date": 2024-09-05T19:00:00.000Z, "value": 868.665}, {"date": 2024-09-06T19:00:00.000Z, "value": 874.389}]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant