I face a little problem with RSuite and schema error handling. Right now I can't translate error messages from Schema because Schema is written outside component, so I can't use hooks. Is it possible to translate error messages outside the component?
const { StringType, DateType } = Schema.Types;
const model = Schema.Model({
username: StringType().isRequired('FORM.ERR.REQUIRED'),
password: StringType().isRequired('FORM.ERR.REQUIRED')
});
export default function login() {
const [formValue, setFormValue] = useState();
const { t } = useTranslation()
const form = useRef();
const formSubmit = () => {
if (form.current.check()) {
console.log(formValue);
}
}
return (
<section className="LOGIN">
<div className="LOGIN__container">
<Form
className="LOGIN__container-form"
model={model}
onChange={formValue => setFormValue(formValue)}
onSubmit={() => formSubmit()}
ref={form}>
<FormGroup>
<FormGroup>
<FormControl placeholder="Username" name="username" style={{width: '100%'}} />
</FormGroup>
<FormGroup>
<FormControl placeholder="Password" name="password" type="password" style={{width: '100%'}} />
</FormGroup>
</FormGroup>
<ButtonToolbar>
<Button appearance="primary" type="submit">
{t('COMMON.SUBMIT')}
</Button>
</ButtonToolbar>
</Form>
</div>
</section>
)
} That's the whole component