Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mutation on remove #14

Open
schneckentempo opened this issue Nov 26, 2018 · 3 comments
Open

Mutation on remove #14

schneckentempo opened this issue Nov 26, 2018 · 3 comments

Comments

@schneckentempo
Copy link

schneckentempo commented Nov 26, 2018

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)
            }
        })
    }
@thomasJang
Copy link
Member

Thank you. I will fix this code.

@thomasJang
Copy link
Member

Version 0.4.0 has just been released. Thank you again.

@thomasJang thomasJang reopened this Nov 27, 2018
thomasJang added a commit that referenced this issue Nov 27, 2018
@thomasJang
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants