我需要帮助渲染我的数组我想在map函数中创建一个条件.但不知何故,我的转换器不是接受和解析错误这是我的代码:
import { getGroups } from '../../actions/groupActions'
import { refreshToken } from '../../actions/authActions'
import { connect } from 'react-redux'
import _ from 'lodash'
import { Link } from "react-router"
class Group extends React.Component {
constructor(props) {
super(props);
this.state = {
groups: []
};
}
componentWillMount(){
this.props.getGroups().then(() => {
console.log('this groups props: ', this.props)
if(this.props.errors.code === 'UNAUTHORIZED'){
this.props.refreshToken().then(() => {
this.props.getGroups()
})
}
})
}
render(){
const groupArr = _.valuesIn(this.props.groups)
return (
<div>
<h1>Groups</h1>
<table className="table table-responsive table-bordered table-condensed">
<thead>
<tr> …Run Code Online (Sandbox Code Playgroud) 
我是Angular 2的新手,我需要路由部分的帮助.我正在使用http://jasonwatmore.com/post/2016/09/29/angular-2-user-registration-and-login-example-tutorial
我收到了一个错误
导出变量'routing'已经或正在使用来自外部模块"/ home/frank/angular/node_modules/@ angular/core/src/metadata/ng_module"的名称'ModuleWithProviders',但无法命名.
这是我的代码
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
// used to create fake backend
import { fakeBackendProvider } from './_helpers/index';
import { MockBackend, MockConnection } from '@angular/http/testing';
import { BaseRequestOptions } from '@angular/http';
import { AppComponent } from './app.component';
import { routing } from './app.routing';
import { AlertComponent } from './_directives/index';
import { AuthGuard } from …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用redux app进行单元测试.所以我需要测试连接的组件,不幸的是我收到了这个错误:
无法读取未定义的属性'contextTypes'我在单元测试中使用酶这是我的组件:
import React from 'react';
import TextFieldGroup from '../common/TextFieldGroup';
import validateInput from '../../server/validations/login';
import { connect } from 'react-redux';
import { login } from '../../actions/authActions';
class LoginForm extends React.Component {
constructor(props) {
super(props);
this.state = {
username: '',
password: '',
errors: {},
isLoading: false
};
this.onSubmit = this.onSubmit.bind(this);
this.onChange = this.onChange.bind(this);
}
isValid() {
const { errors, isValid } = validateInput(this.state);
if (!isValid) {
this.setState({ errors });
}
return isValid;
}
onSubmit(e) {
e.preventDefault();
if (this.isValid()) {
this.setState({ …Run Code Online (Sandbox Code Playgroud) 这是我的 API 请求
public IEnumerator Login(string bodyJsonString)
{
Debug.Log(bodyJsonString);
UnityWebRequest req = UnityWebRequest.Post("localhost:3000/login", bodyJsonString);
req.SetRequestHeader("content-type", "application/json");
yield return req.SendWebRequest();
if (req.isNetworkError || req.isHttpError)
{
Debug.Log(req.error);
}
else
{
Debug.Log("Form upload complete!");
}
}
Run Code Online (Sandbox Code Playgroud)
它返回错误状态代码 500,并在服务器上返回错误 Unexpected token % in JSON atposition 0","severity
这是我的协程调用
public void submitLogin()
{
_username = userInputField.GetComponent<InputField>().text;
_password = passwordInputField.GetComponent<InputField>().text;
Debug.Log("username" + _username);
Debug.Log("password" + _password);
string body = "{'username':'" + _username + "','password','" + _password + "'}";
//API Call
authChexi = new Auth();
StartCoroutine(authChexi.Login(body));
}
Run Code Online (Sandbox Code Playgroud)
如果您对如何处理我的表单有任何想法,请告诉我。谢谢
react-redux ×2
reactjs ×2
angular ×1
c# ×1
enzyme ×1
json ×1
react-jsx ×1
redux ×1
unit-testing ×1
unity-webgl ×1