我试图使用React refs在安装时聚焦Redux-Form字段.
当我尝试this.refs.title.getRenderedComponent().focus()时componentDidMount,会抛出一个错误:
edit_fund.js:77 Uncaught TypeError: Cannot read property 'getRenderedComponent' of undefined
当我在console.log this.refs中时,它主要是一个空对象,有时将'title'标识为ref,但它不可靠.
我错误地使用了refs吗?我的代码在下面供参考.
componentDidMount = () => {
this.refs.title
.getRenderedComponent()
.focus();
}
Run Code Online (Sandbox Code Playgroud)
...
<Field
id="title"
name="title"
component={FormInput}
type="text"
ref="title" withRef
/>
Run Code Online (Sandbox Code Playgroud) 我正在使用Cloud Firestore并拥有一组文档.对于集合中的每个文档,我想更新其中一个字段.
使用事务执行更新效率很低,因为在更新数据时我不需要读取任何数据.
批量更新似乎是正确的方向,但是文档不包括一次更新多个文档的示例.请参见此处:批量写入
java firebase firebase-realtime-database google-cloud-firestore
当我运行开发服务器时,出现以下错误。
Proxy error: Could not proxy request /graphql from localhost:3000 to http://localhost:3010.
See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNRESET).
Run Code Online (Sandbox Code Playgroud)
它阻止我将任何请求从开发服务器代理到 API。
经过调试后,我意识到这不是代码的问题,因为我和我的同事正在同一个存储库中工作,而他没有这个错误。另外,有时如果我重新启动终端,错误就会在再次出现之前消失。
非常感谢有关此问题的根源是什么以及如何解决它的指导。
我最近将我的项目从 Meteor 迁移到 Webpack,并且在尝试使用 Materialize.css 构建我的 UI 时遇到错误。自定义实现函数(例如$(...).tooltip)会导致在控制台中抛出 Uncaught TypeError。这不允许我在我的应用程序中使用 Materialize。
在 webpack 应用程序中尝试使用 Materialize 时,还有其他人遇到过这些类型的错误吗?任何有关如何解决这些问题的方向将不胜感激。谢谢!
我用来在目录根目录下的 index.js 中加载 Materialize 模块及其依赖项的代码如下。
索引.js:
import 'materialize-loader';
import 'materialize-css/dist/css/materialize.css';
window.jQuery = require('jquery');
window.$ = require('jquery');
import 'materialize-css/dist/js/materialize.js';
import 'materialize-css/js/init.js';
Run Code Online (Sandbox Code Playgroud) 我正在使用 Firestore,每当我尝试data从查询快照调用文档上的方法时,都会收到此错误。这是我的代码。
let snapshot: FirebaseFirestore.QuerySnapshot<FirebaseFirestore.DocumentData>;
try {
snapshot = await admin.firestore()
.collection("products")
.where("email", "==", email)
.get();
} catch (error) {
// error code
}
if (snapshot.empty) {
// does not exist
return;
}
const docs: DbSubscription[] = [];
snapshot.forEach(({ data, id }) => {
// this is where error is thrown
docs.push({ ...data(), id } as DbSubscription);
});
Run Code Online (Sandbox Code Playgroud)
我确认该文档存在并且具有数据,因为登录snapshot?.docs[0]?.data()到控制台会输出预期的内容。但是调用data上面的方法会引发错误。
任何人都知道为什么会发生这种情况?非常感激!
firebase ×2
debugging ×1
econnreset ×1
java ×1
javascript ×1
materialize ×1
node.js ×1
proxy ×1
reactjs ×1
redux-form ×1
sockets ×1
webpack ×1