输入元素不应从受控状态切换到非受控状态反之亦然 React.js

问题描述

我使用MERN堆栈从github克隆了一个简单的CRUD应用程序项目。我试图在现有类别中添加“语言”类别:“用户名”,“描述”,“持续时间”和“日期”。我遍历了代码并添加了类似于其他类别设置语言的语言,但是当我尝试编辑现有帖子以添加语言时,出现此错误。

import sys
import random
import time

rounds=0

def user1bot(rounds):
    print("")
    input("Enter A to roll the Dice!")
    userscore=random.randint(1,6)
    print("You Scored: "+str(userscore))
    rounds=rounds+1
    print(rounds)
    userbot(rounds)

def userbot(rounds):
    print("Bot is rolling a dice...")
    time.sleep(3)
    userscorebot=random.randint(1,6)
    print("Bot Scored: "+str(userscorebot))
    rounds=rounds+1
    print(rounds)
    user1bot(rounds)

while rounds<5:
    user1bot(rounds)
    continue
else:
    sys.exit()
    

我对为什么在Warning: A component is changing a controlled input of type text to be uncontrolled. Input elements should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled input element for the lifetime of the component. in input (at edit-exercise.component.js:156) in div (at edit-exercise.component.js:154) in form (at edit-exercise.component.js:109) in div (at edit-exercise.component.js:107) in EditExercise (created by Context.Consumer) in Route (at App.js:18) in div (at App.js:14) in Router (created by BrowserRouter) in BrowserRouter (at App.js:13) in App (at src/index.js:7) in StrictMode (at src/index.js:6) 处收到此错误感到困惑,因为代码的设置与持续时间相同,而持续时间仅比第156行稍高,并且持续时间没有错误。>

我查了一下这个错误并读了几篇文章,看来正在发生的事情是语言持有一个空值或类似的东西,我不确定为什么其余的代码仍能正常工作收到错误。

edit-exercise.component.js:

edit-exercise.component.js:156

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...