m03a3a17 m03a3a17 - 3 months ago 11
React JSX Question

Uncaught ReferenceError: MyOwnInput is not defined in react.js(formsy react)

I am trying to validate my Login form and using example on https://github.com/christianalfoni/formsy-react

I am new to both react and formsy.

I am getting error as "Uncaught ReferenceError: MyOwnInput is not defined"

my code looks like this

import Formsy from 'formsy-react';
import React, { Component } from 'react';
import {Link} from "react-router";
import {withRouter} from 'react-router';


export default withRouter(class Testing extends React.Component{



constructor(props){
super(props);
this.state= {
canSubmit: false
};
}

enableButton() {
this.setState({
canSubmit: true
});
}
disableButton() {
this.setState({
canSubmit: false
});
}
submit(model) {
someDep.saveEmail(model.email);
}
render() {
return (
<Formsy.Form onValidSubmit={this.submit} onValid={this.enableButton} onInvalid={this.disableButton}>
<MyOwnInput name="email" validations="isEmail" validationError="This is not a valid email" required/>
<button type="submit" disabled={this.state.canSubmit}>Submit</button>
</Formsy.Form>
);
}
});

Answer

Missing import for MyOwnInput

It will be something like:

import MyOwnInput from '../../components/common/MyOwnInput';