Hi, I'm new to being so sorry for the main question.
I am trying to define a method in const
const Age = t.refinement(t.Number, (n) => return n >= 18);
However, linter doesn't like that I have a return keyword in a method. Here is the class
import React, { Component } from 'react'
import { postFeedback } from 'Services/Config'
import { render } from 'react-dom';
import t from 'tcomb-form';
const FormSchema = t.struct({
name: t.String,
age: t.Number,
rememberMe: t.Boolean
})
const Age = t.refinement(t.Number, (n) => return n >= 18);
export class Form extends Component {
onSubmit = (evt) => {
evt.preventDefault()
const value = this.refs.form.getValue()
console.log(value)
console.log("validation -> " + this.refs.form.validate())
if (value) {
console.log(value)
}
}
render() {
return (
<form onSubmit={this.onSubmit}>
<t.form.Form ref="form" type={FormSchema} />
<div className="form-group">
<button type="submit" className="btn btn-primary">Save</button>
</div>
</form>
)
}
}
export default Form
source
share