2017-05-11 2 views
0

오류는 getValidationState() 및 complete()를 가리 킵니다. 그러나 소스를 찾을 수 없었습니다. 유효성 검사 상태가 사용자가 지정한 입력 길이에 따라 변경되는 입력을 만들려고합니다.최대 호출 스택 초과 오류

import React, { Component } from 'react'; 
import 'bootstrap/dist/css/bootstrap.css'; 
import 'bootstrap/dist/css/bootstrap-theme.css'; 
import { FormGroup, ControlLabel, FormControl, HelpBlock } from 'react-bootstrap'; 

class FormGroupValidation extends Component { 

constructor(props) { 
    super(props); 
    this.state = { 
     value: '', 
     completed: false 
    }; 

    this.getValidationState = this.getValidationState.bind(this); 
    this.complete = this.getValidationState.bind(this); 
    this.unComplete = this.unComplete.bind(this); 
    this.toggleComplete = this.toggleComplete.bind(this); 
    this.handleChange = this.handleChange.bind(this); 
} 
getValidationState() { 
    const length = this.state.value.length; 

    if (this.ThresholdType === 'max') { 
     if (this.props.errorLen && length <= this.props.errorLen) { 
      return 'error'; 
     } else if (this.props.warnLen && length <= this.props.warnLen) { 
      this.unComplete(); 
      return 'warning'; 
     } else if (this.props.successLen && length <= this.props.successLen) { 
      this.complete(); 
      return 'success'; 
     } 
    } else { 
     if (this.props.successLen && length >= this.props.successLen) { 
      this.complete(); 
      return 'success'; 
     } else if (this.props.warnLen && length >= this.props.warnLen) { 
      return 'warning'; 
     } else if (this.props.errorLen && length >= this.props.errorLen) { 
      this.unComplete(); 
      return 'error'; 
     } 
    } 
} 
complete() { 
    if (!this.state.complete) this.toggleComplete(); 
} 
unComplete() { 
    if (this.state.complete) this.toggleComplete(); 
} 
toggleComplete() { 
    this.setState({completed: !this.state.completed}); 
} 
handleChange(e) { 
    this.setState({ value: e.target.value }); 
} 
render() { 
    return (
    <form> 
     <FormGroup 
      controlId="formBasicText" 
      validationState={this.getValidationState()} 
     > 
      <ControlLabel>Working example with validation</ControlLabel> 
      <FormControl 
      type="text" 
      value={this.state.value} 
      placeholder="Enter text" 
      onChange={this.handleChange} 
      /> 
      <FormControl.Feedback /> 
      <HelpBlock>Validation is based on string length. </HelpBlock> 
     </FormGroup> 
    </form> 
    ); 
} 
} 

export default FormGroupValidation; 

답변

2
this.complete = this.getValidationState.bind(this); 

this.complete = this.complete.bind(this); 

되어야한다)

관련 문제