使用 DraftJS 和 Meteor Js 应用程序所涉及的代码任务 - 进行实时预览,其中来自 DraftJS 的文本将被保存到 DB 并从 DB 显示在另一个组件上。
但问题是一旦数据来自数据库,我尝试编辑 DraftJS 光标移动到开头。
代码是
import {Editor, EditorState, ContentState} from 'draft-js';
import React, { Component } from 'react';
import { TestDB } from '../api/yaml-component.js';
import { createContainer } from 'meteor/react-meteor-data';
import PropTypes from 'prop-types';
class EditorComponent extends Component {
constructor(props) {
super(props);
this.state = {
editorState : EditorState.createEmpty(),
};
}
componentWillReceiveProps(nextProps) {
console.log('Receiving Props');
if (!nextProps) return;
console.log(nextProps);
let j = nextProps.testDB[0];
let c = ContentState.createFromText(j.text);
this.setState({ …Run Code Online (Sandbox Code Playgroud) 我从 3 个不同的 API 中提取数据,并且希望将所有这些结果合并到一个数组中。
我想做到这一点的正确方法是使用 Promise:
var function1 = new Promise((resolve, reject)=>{
...
resolve();
});
var function2 = new Promise((resolve, reject)=>{
...
resolve();
});
var function3 = new Promise((resolve, reject)=>{
...
resolve();
});
Promise.all([function1, function2, function3]).then(function(values){
// Values are all here!
});
Run Code Online (Sandbox Code Playgroud)
我怎样才能再次调用所有的承诺并通过Promise.all每一秒加入它们?
我试过了
setInterval(function(){
Promise.all([function1, function2, function3]).then(function(values){
// Values are all here and up to date!
});
}, 1000)
Run Code Online (Sandbox Code Playgroud)
没有成功。
感谢您的帮助!
目前使用Cognito Javascript SDK,当我发送的用户名存在或不存在时,我有点惊讶地收到警告:
这是我正在使用的代码:
login(username, password) {
const authenticationData = {
Username : username,
Password : password,
};
const authenticationDetails = new AuthenticationDetails(authenticationData);
const userPool = new CognitoUserPool(this.poolData);
const userData = {
Username : username,
Pool : userPool,
};
this.cognitoUser = new CognitoUser(userData);
this.cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: function (result) {
console.log(result);
},
newPasswordRequired: function(...) {
},
onFailure: function(err) {
console.log(err);
},
});
}
Run Code Online (Sandbox Code Playgroud)
如果我设置username为mytest(现有用户)并使用错误的密码,则会收到以下错误:
“NotAuthorizedException” 用户名或密码不正确。
没关系。但如果我设置username为test12345(非现有用户),我会收到此错误:
“UserNotFoundException” 用户不存在。
我认为告诉最终用户用户名是否存在并不真正安全。
我错了吗?难道是我做错了什么? …
早上好,
我的应用程序启动时有两个异步调用:一个获取推送通知的设备令牌,另一个尝试将用户登录到Facebook.
如果我没有两个异步调用的结果,我不能继续申请过程.
目前,我正在做这样的事情:两个布尔didFBConnect和didDeviceTokenObtained.
我正在一个线程中运行(显然非常糟糕):
while(!(didFBConnect && didDeviceTokenObtained)){
}
myFunctionToContinue();
Run Code Online (Sandbox Code Playgroud)
你知道处理这种情况的正确方法是什么吗?
BR
我正在尝试调整我的iphone 6应用程序.
在将自定义背景图像设置到导航栏之前,一切运行良好:
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbarbg.png"] forBarMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)
由于此图像是为iphone 4/5制作的,因此宽度不足.
你知道如何为iphone6设置正确的图像吗?
我试图将我的图像命名为navbarbg@3x.png或navabarbg-667h@3x.png,但它不会改变任何内容.
任何的想法 ?
更新:我添加了我使用的图像:

asynchronous ×2
ios ×2
javascript ×2
aws-amplify ×1
draftjs ×1
iphone ×1
meteor ×1
objective-c ×1
promise ×1
reactjs ×1