Skip to content

Crash on unsubscribe of renamed field #191

Description

@dj0nes

Are you submitting a bug report or a feature request?

Bug report

What is the current behavior?

When invoking Tools.renameField, the field is renamed in MutableState, but final-form will still try to unregister with the old field name, which crashes the page with Cannot read property 'validators' of undefined.

What is the expected behavior?

final-form should unregister the renamed field name, or at least fail gracefully when trying to unsubscribe a non-existent field.

Sandbox Link

https://codesandbox.io/s/rwj3m5rlmp

What's your environment?

latest final-form, any browser

Other information

It looks like deleting field subscribers happens in the rename here, and again in the unsubscribe here, which has a reference to the old field name.

I'm happy to submit a PR for checking before deleting keys in the unsubscribe, or other fixes if there's a better way!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions