I want to use a TextField from Material-UI with react-final-form (https://github.com/final-form/react-final-form).
The main question is "How to get values
object?"
I cannot get it from TextField.
The result is:
I've already tried different examples but nothing works.
My code:
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Button from '@material-ui/core/Button';
import Card from '@material-ui/core/Card';
import './loginForm.css';
import { Form, Field } from 'react-final-form';
const handleSubmit = (event, values) => {
console.log('onsubmit event target ', event.target);
event.preventDefault();
console.log('onSubmit values: ', values);
};
const onChange = (event) => {
console.log('on changed: ', event.target.value);
};
const LoginForm = () => (
<Card className="card">
<Form
onSubmit={handleSubmit}
onChange={onChange}
render={({ values }) => (
<form className="login-form" onSubmit={handleSubmit}>
<Field
name="pin"
component={TextField}
id="standard-name"
label="PIN"
value={values}
onChange={onChange}
/>
<Button
type="submit"
onClick={handleSubmit}
variant="contained"
color="primary"
className="login-btn"
>
Sign in
</Button>
</form>
)}
/>{' '}
</Card>
);
export default LoginForm;
versions:
"@material-ui/core": "^3.9.2",
"react-final-form": "^4.0.2",