Hi have added a new text box under the render which is Units and it works fine in local machine but throws error in server built . Does it has to be mounted with the component . Am new to reactjs could some one suggest .
- import React from 'react';
-
- class TextboxInputView extends React.Component {
-
- constructor(props) {
- super(props);
- this.state = {
- value: ''
- }
- }
-
- onValueChanged(e) {
- var newValue = e.target.value;
- this.setState({ value: newValue });
- if (this.props.valueChanged != null)
- this.props.valueChanged(newValue);
- }
-
- render() {
- var unitsCheck = "";
- if (this.props.data.Unit != "") { unitsCheck = <input id="Units" className='col-md-4' Style='font-weight:normal' readOnly type="text" value={this.props.data.Unit} /> }
- return <div key={this.props.Id}>
- <label>
- <input type="text" className='col-md-6' value={this.state.value} onChange={(e) => this.onValueChanged(e)} /> {this.props.Name}
- {unitsCheck}
- </label>
- </div>;
- }
-
- getDefaultValue() {
- var defaultValue = null;
- if (this.props.defaultValues != null && this.props.defaultValues.length === 1 && this.props.defaultValues[0] !== '')
- defaultValue = this.props.defaultValues[0];
- return defaultValue;
- }
-
- componentDidMount() {
- var defaultValue = this.getDefaultValue();
-
- if (defaultValue != null && this.state.value !== defaultValue) {
- this.onValueChanged({ target: { value: defaultValue } });
- }
- }
-
- componentWillReceiveProps(nextProps) {
- if (this.props !== nextProps && nextProps.isResetValues) {
- let defaultValue = this.getDefaultValue();
- defaultValue = defaultValue === null ? '' : defaultValue;
-
- if (this.state.value !== defaultValue) {
- this.onValueChanged({ target: { value: defaultValue } });
- }
- }
- }
- }
-
- export default TextboxInputView