reactjs - Quill(react markdown)编辑器在最初使用 props 值渲染时重新渲染。这正常吗?
问题描述
这似乎是不必要的重新渲染。发生这种情况正常吗?为什么它不在一次渲染中做到这一点?
我指的是以下编辑器:https ://quilljs.com/docs/quickstart/
class Editor extends React.Component {
constructor(props) {
super(props);
this.timeout = 0;
this.state = { text: this.props.description }; // You can also pass a Quill Delta here
this.handleChange = this.handleChange.bind(this);
}
handleChange(value) {
this.setState({ text: value });
if (this.timeout) clearTimeout(this.timeout);
this.timeout = setTimeout(() => {
this.props.addDescription(value);
}, 1000);
}
render() {
return (
<div className="text-editor">
<ReactQuill
value={this.state.text}
onChange={this.handleChange}
modules={this.modules}
formats={this.formats}
placeholder={'Write a Description'}
/>
</div>
);
}
}
export default Editor;
解决方案
推荐阅读
- java - 如何转换列表
在Java中没有“”的逗号分隔字符串 - python - 在 Python 中将 20 列聚合为一列的更快方法
- c - 为什么“传递不兼容指针类型的参数”警告
- sql - 在 Postgres 中继承独特约束的最佳解决方法是什么?
- html - Angular 6 - 从 httpClient 获取 csv 响应
- javascript - 量角器 if else 语句与期望
- video - Microsoft Media Foundation / UVC ReadSample() 回调
- date - 表示为年、月、日的两个日期之间的差异(在一列中)
- node.js - RSA 使用错误的私钥成功解密
- laravel - Laravel Socialite facebook 登录:无法加载 URL:此 URL 的域不包含在应用程序的域中