Skip to content

Typeerror: undefined is not an object (evaluating '_this.setState') #3

@glitchwizard

Description

@glitchwizard

I'm getting the following error:

image

with the following component:

import React, { useState } from 'react';
import Background from './components/background';
import { StyleSheet, View, Text, StatusBar } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import WeekdayPicker from "react-native-weekday-picker";

<link href="https://fonts.googleapis.com/css2?family=Lato:wght@300&display=swap" rel="stylesheet"></link>

export default function App() {
  
  let days = {
    1: 0,
    2: 0,
    3: 0,
    4: 0,
    5: 0,
    6: 0,
    0: 0
  };
  
  const handleChange = (days) => { this.setState(days) }

  return (
    <View style={styles.container}>
      <View style={styles.calApptComponentContainer}>
        <View style={styles.calHeader}>
          <Text style={{ borderColor: "green", borderWidth: 1, flex: 1 }}>
            Tues, Jan 14
          </Text>
          <View
            style={{
              borderColor: "purple",
              borderWidth: 1,
              flex: 1,
              alignItems: "flex-end",
            }}
          >
            <Icon name="calendar-blank" size={30} color="#000" />
          </View>
        </View>
            <WeekdayPicker
              days={days}
              onChange={handleChange}
              style={styles.picker}
              dayStyle={styles.day}
            />
        <View style={styles.calMeetingTimeSelectorContainer}>
          <Text>CalMeetingTimeSelector</Text>
        </View>
        <View style={styles.calFooter}>
          <Text>CalFooter</Text>
        </View>
      </View>
      <Background />
      <StatusBar />
    </View>
  );
}

Am I setting this up incorrectly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions