[英]React Fabric TextField becomes read only after adding value property
I have been trying to figure out how to handle value changes in React Fabric TextFields.我一直在试图弄清楚如何处理 React Fabric TextFields 中的值变化。 The problem is every time I set the value property, the component becomes read only.
问题是每次设置value属性时,组件都会变为只读。 If is use the defaultValue property, everything works fine, apart from the fact I need this input to be controlled.
如果使用defaultValue属性,则一切正常,除了我需要控制此输入的事实。 I am using React Fabric inside a SharePoint Framework solution.
我在 SharePoint 框架解决方案中使用 React Fabric。
What I currently have is this:我目前拥有的是:
...
this.state = {
title: ''
}
this.handleInputChange = this.handleInputChange.bind(this);
}
public handleInputChange(id, value) {
this.setState({
[id]: value
});
}
public render(): React.ReactElement<IQuoteAppProps> {
return (
<TextField
label='Title'
onChanged={(value) => this.handleInputChange('title', value)}
value={this.state.title}
required
/>
)
}
Does anyone know how to correctly set this up?有谁知道如何正确设置? I have included two screenshots as well.
我还包括了两个屏幕截图。
Edit: I literally copied and pasted an example from the developer page mentioned below and it is still not working.编辑:我从下面提到的开发人员页面中复制并粘贴了一个示例,但它仍然无法正常工作。 The component on their website is working fine and can be edited.
他们网站上的组件运行良好,可以编辑。 The only thing I now have in mind is whether React Fabric is not colliding with something inside SharePoint Framework.
我现在唯一想到的是 React Fabric 是否没有与 SharePoint 框架内的某些内容发生冲突。
Office UI Fabric TextField: https://developer.microsoft.com/en-us/fabric#/components/textfield Office UI Fabric TextField: https : //developer.microsoft.com/en-us/fabric#/components/textfield
After creating a new SPFx project and testing it there, everything was working fine.在创建一个新的 SPFx 项目并在那里对其进行测试后,一切正常。 I decided to delete the node_modules folder and run npm install to install all the packages from scratch.
我决定删除node_modules文件夹并运行npm install从头开始安装所有包。 It magically started working.
它神奇地开始工作。
Does anybody know what exactly could be causing this?有谁知道究竟是什么导致了这种情况?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.