You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently ReactPy using a function called strictly_equals to determine if set_state is setting itself to a duplicate value.
This sometimes relies on python's is keyword to check identity.
Proposed Actions
Using is to check equality in Python doesn't exactly behave the same as the javascript equivalent (Object.is). The current set_state design is effectively if the old/new memory references are the same, which doesn't equate to whether their values are the same. This is honestly a bit annoying, and results in a re-renders in a lot re-renders in scenarios were it was completely unneeded.
Python's __eq__ method is far more similar to JavaScript than Python's is. So realistically, we should be attempting to do an __eq__ check whenever possible.
Current Situation
Currently ReactPy using a function called
strictly_equals
to determine ifset_state
is setting itself to a duplicate value.This sometimes relies on python's
is
keyword to check identity.Proposed Actions
Using
is
to check equality in Python doesn't exactly behave the same as the javascript equivalent (Object.is
). The currentset_state
design is effectively if the old/new memory references are the same, which doesn't equate to whether their values are the same. This is honestly a bit annoying, and results in a re-renders in a lot re-renders in scenarios were it was completely unneeded.Python's
__eq__
method is far more similar to JavaScript than Python'sis
. So realistically, we should be attempting to do an__eq__
check whenever possible.The text was updated successfully, but these errors were encountered: