Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

309
Views
React Native simple useState does not work, state is staying 'undefined' and "setState is not a function"

I have just a simple React-Native Component that uses useState as a test if it works. When I set the userstate, and I just print it, it logs 'undefined'. Also when I call setUser, it throws an error, that setUser is not a function. Whats wrong with my Setup?:

import { StyleSheet, Text, View, TextInput, Button, Seperator, Pressable } from 'react-native'
import React, {useState, useEffect} from 'react'
import colors from '../theme/colors.style.js'
import NetInfo from '@react-native-community/netinfo';
import { checkConnected } from '../utils/Netinfo.js';

export default function  MachineManager() {
  const {connectStatus, setConnectStatus} = useState(false);
  const {user, setUser} = useState("martin");
  console.log(user);

  return (
    <View style={styles.container}>
      <View style={styles.connectorMenu}>
        <View style={styles.shadowView}>
          <View style= {styles.connectionMenuHeader}>
            <Text style={styles.connectionMenuHeaderText}>Verbundenes Gerät</Text>
          </View>
          <View style={styles.inputRow}>
            <Text style={styles.inputLabel}>SSID:</Text>
            <TextInput placeholder="SSID Kennung" style={styles.input}/>
          </View>
          <View style={styles.inputRow}>
            <Text style={styles.inputLabel}>Passwort:</Text>
            <TextInput placeholder="Passwort" style={styles.input}/>
          </View>
          <View style={styles.connectionControl}>
            <View style={styles.connectionControlStatus}>
              <Text style={styles.connectionControlStatusText}>Status: Nicht Verbunden</Text>
              <Text style={styles.connectionControlStatusText}>{user}</Text>
            </View>
            <View style={styles.connectionControlConnect}>
              <Pressable style={styles.connectButton}>
                <Text style={styles.connectButtonText}>Verbinden</Text>
              </Pressable>
            </View>
          </View>
        </View>
      </View>
    </View>
  )
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The syntax is incorrect. It needs to be -

const [connectStatus, setConnectStatus] = useState(false);
const [user, setUser] = useState("martin")
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!