0
votes

I'm new on React hooks. I was trying to replace an state (class) for a useState hook. Something simple like the code bellow. The problem is in the line const [showPass, setShowPass] = useState[false], which I believe the syntax is correct

enter image description here

import React, { useState } from 'react';
import { View, Text, TextInput, TouchableOpacity } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialIcons'
import { Theme } from '../theme';

const Input = ({ icon, password, number, placeholder, value, onChangeText, colored, style, containerStyle, label }) => {
    const [showPass, setShowPass] = useState[false];

    return (
        <>
        </>
    );
}
2

2 Answers

0
votes

Syntax error

    const [showPass, setShowPass] = useState[false]; // change to useState(false)

0
votes

Change the line:

const [showPass, setShowPass] = useState[false];

to the following:

const [showPass, setShowPass] = useState(false);

It's a silly sintax error, useState uses parenthesis, not brackets.

Should be working fine now.