Questions tagged [controlled-component]

89 questions
0
votes
2 answers

What can happen if I don't declare a controlled component?

import React, { useState } from "react"; function App() { const [fName, setfName] = useState(""); function changefName(event) { setfName(event.target.value); } return (

Hello {fName} …

0
votes
0 answers

Custom textarea objects in React with controlled contentEditable

I'm trying to create a textarea where on enter the input is converted to a custom component (e.g. email) as show below. Any suggestions on how to create this in react? I have tried creating this using a contentEditable div with the values being…
0
votes
1 answer

Changing input of controlled component changes property value to undefined

I have an array of default values in a useState. Upon an onChange event via a select, the properties in the array are changed to undefined. I've been reading up on controlled components and I think I've missed something silly. Here is a…
paq
  • 87
  • 8
0
votes
1 answer

Change the input initial value of controlled component in React

I have this input component const FOO = props => { const [inputValue, setInputValue] = useState( props.editState ? props.initialValue : "" ); const setSearchQuery = (value) => { setInputValue(value); props.onSearch(value); …
eksoo
  • 81
  • 1
  • 6
0
votes
1 answer

Having problem with controlled form validation in Reactjs

Hi i'm newbie learning to code and start with Js, Reactjs. I convert my code from class component to functional component and then my validation stop working. i have looking around but yet to find answer, can someone help? ^^" export default…
Kisei
  • 1
  • 1
0
votes
1 answer

Checking one checkbox in a group, controlled component Typescript and React

all. I have a controlled component I am building in Storybook using React and Typescript. As an uncontrolled component my Checkbox works fine. I am a little stuck with my thought process and logic with it being controlled and with multiple…
0
votes
1 answer

how to solve "TypeError: Cannot read properties of undefined (reading 'state') at checkGuess (Flashcard.js:34:1)" when trying to post form data?

I have a simple react flashcard app that sends data to the backend about the flashcard including the question, answer choices, and the answer that the user guessed along with the correct answer. I am trying to post the user's name that they enter…
sleepysanjay
  • 37
  • 1
  • 5
0
votes
1 answer

How to get the values from