react-multi-email icon indicating copy to clipboard operation
react-multi-email copied to clipboard

Mutation on remove

Open schneckentempo opened this issue 7 years ago • 3 comments

Following code mutates the emails, which leads my state to be corrupted:

https://github.com/jsdevkr/react-multi-email/blob/c45542748e750757b5c27a6aec6f2c1aa6680584/src/react-multi-email/ReactMultiEmail.tsx#L109

this code should be correct:

removeEmail = (index: number) => {
        this.setState(prevState => ({
            emails: prevState.emails.splice(index, 1),
        }), () => {
            if (this.props.onChange) {
                this.props.onChange(this.state.emails)
            }
        })
    }

schneckentempo avatar Nov 26 '18 12:11 schneckentempo

Thank you. I will fix this code.

thomasJang avatar Nov 26 '18 12:11 thomasJang

Version 0.4.0 has just been released. Thank you again.

thomasJang avatar Nov 26 '18 13:11 thomasJang

v0.4.1 has just been released. Thank you again.

thomasJang avatar Nov 27 '18 01:11 thomasJang