Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Component doesn't updates on path change #388

Closed
gbiryukov opened this issue Jun 13, 2017 · 2 comments
Closed

Component doesn't updates on path change #388

gbiryukov opened this issue Jun 13, 2017 · 2 comments

Comments

@gbiryukov
Copy link
Contributor

Version

  • tcomb-form v0.9.16
  • react v0.15.4

Expected behaviour

Components gets re-rendered when its path changes.

Actual behaviour

tcomb Component class has shouldComponentUpdate defined that prevent component update on path changes

Steps to reproduce

  1. go to demo (source)
  2. add two elements
  3. remove first one

You will see that remaining element will have path 1.title but it's actual path 0.title.
If you will try to type something into this textbox it will pass incorrect path to form onChange callback

It quite easy to fix in t.form.Component shouldComponentUpdate method

@gcanti
Copy link
Owner

gcanti commented Jun 14, 2017

@gbiryukov thanks for the detailed bug report, would you like to send a PR?

@gbiryukov
Copy link
Contributor Author

sure, np

gbiryukov added a commit to gbiryukov/tcomb-form that referenced this issue Jun 14, 2017
gcanti pushed a commit that referenced this issue Jun 16, 2017
* add update on path change test

* respect path changes in Component `shouldComponentUpdate` method (#388)

* add `isArraysDiffers` util

* compare path array by value instead of reference

* rename `isArraysDiffers` -> `isArraysShallowDiffers`
@gcanti gcanti closed this as completed Jun 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants