Solve the problem that the pinyin value of oninput events in react will be accumulated under the ios Chinese input method.

class Value extends React.Component {
    constructor(props) {
        super(props)
        this.inputRef = ""
        this.flag = true
    }
    render() {
        const isChangeable = isEditable && isTypeable
        return (
            <input
                ref={(c) => { this.inputRef = c }}
                type="text"
                value={value || ""}
                placeholder={placeholder}
                onCompositionStart={() => { this.flag = false }}
                onCompositionEnd={() => { this.flag = true }}
                onChange={() => setTimeout(() => {
                    if (this.flag && isChangeable) {
                        onChange(this.inputRef.value)
                    }
                }, 100)}
            />
    
        )
    }
}

try to solve the problem of onCompositionStart and onCompositionEnd,onChange. Debugging finds that only onCompositionStart events will be executed when entering Chinese, and input can only get the input value after adding these events.

related codes

/ / Please paste the code text below (do not replace the code with pictures)

The expected result of

is that the input Chinese on all devices is displayed normally? What you actually see is that the ios device will get the pinyin value accumulation under the above input method, and the Android and PC ends are normal?

Aug.10,2021

I also encountered, how to solve?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e43d0d-44a58.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e43d0d-44a58.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?