Antd does not update input value with onChange?

Viewed 413

I've been racking my brains for a while trying to update the input value to add a mask, but with no results the input doesn't update the value at all.

 <Input
            placeholder={'CNPJ'}
            onChange={(e) => {
              e.currentTarget.value = 'fdsfsd'

            }}
            ref={props.cnpj}/>
          <input onChange={(e) => {
            e.currentTarget.value = 'fdsfsd'
          }}/>
1 Answers

Maybe this help you.

import { useState } from "react";

export default function Wrapper() {
    const [value, setValue] = useState("");
    const onChange = (e) => {
        setValue(e.target.value);
    };

    return (
        <>
            <div>
                <input value={value} onChange={onChange} />
                <p>My Input value: {JSON.stringify(value)}</p>
            </div>
        </>
    );
}
Related