NewOldMax / react-form-validator-core

Core validator component for react forms
MIT License
95 stars 44 forks source link

Why there is no ValidatorForm.removeValidationRule? #51

Closed mgustus closed 5 years ago

mgustus commented 5 years ago

Hi,

After adding a custom validation rule with ValidatorForm.addValidationRule in componentDidMount(), I think it is reasonable to remove it in componentWillUnmount(). It looks like there could be a memory leak because the custom rule function stays in the Rules collection with all its closures. Why there is no ValidatorForm.removeValidationRule?

Thanks.

NewOldMax commented 5 years ago

There is no memory leak there. Only if you add new rules every time with unique names. But removeValidationRule function makes sense, I will add it later

mgustus commented 5 years ago

The problem is that Rules is a static collection that is never destroyed. So if I add a rule that uses state or props of some component, this component will remain in memory forever.

NewOldMax commented 5 years ago

@mgustus check the 0.6.4 version

mgustus commented 5 years ago

great! Thank you 👍