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
Dispatching an interaction state from a styled component that has no corresponding state mapping defined makes app unresponsive and finally results in a crash.
Looks the issue is caused by an infinite loop in withStyledProps method of StyleConsumerService. In case state mapping is missing for dispatched interaction state, the getGeneratedStyleMapping returns undefined, this makes the withStyledProps method calling itself but with same values for interaction param.
Create styled component with custom component mapping, include mapping definition for one state (e.g. focused)
Dispatch interaction state other then the mapped one (e.g. active).
Expected behavior
Dispatching an interaction state without a corresponding mapping shouldn't make app unresponsive nor crash. Non-mapped interaction state should be ignored during style calculation.
@arendlagendijk thanks for reporting and giving a detailed description.
It looks like it's a super-minor for the library itself, because dispatching wrong states is a first of all a user issue. Is it blocking your app somehow?
Non-mapped interaction state should be ignored
Yes, and it's actually what it does for the other cases, giving you a warning and falling back to the default config. Seems like states is the part that couldn't be handled same way, so I guess it would be nice if we can handle it with an additional warning.
It looks like it's a super-minor for the library itself, because dispatching wrong states is a first of all a user issue.
Agree, only debugging to find cause is quite hard when app goes into unresponsive state. That's the main reason to report the issue and to make the library even better of course.
Is it blocking your app somehow?
No it isn't, at least not after discovering what caused the issue. Just have to be careful when working on styles components and make sure mappings for dispatched states do exist.
Seems like states is the part that couldn't be handled same way, so I guess it would be nice if we can handle it with an additional warning.
Yes that would definitely do it. Checked the fix you implemented, works like a charm! Thanks.
🐛 Bug Report
Dispatching an interaction state from a styled component that has no corresponding state mapping defined makes app unresponsive and finally results in a crash.
Looks the issue is caused by an infinite loop in
withStyledProps
method ofStyleConsumerService
. In case state mapping is missing for dispatched interaction state, thegetGeneratedStyleMapping
returnsundefined
, this makes thewithStyledProps
method calling itself but with same values for interaction param.react-native-ui-kitten/src/components/theme/style/styleConsumer.service.ts
Line 63 in 0eeba5e
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Dispatching an interaction state without a corresponding mapping shouldn't make app unresponsive nor crash. Non-mapped interaction state should be ignored during style calculation.
Link to runnable example or repository
https://github.com/arendlagendijk/uik-dispatch-nonmapped-interactionstate-issue
UI Kitten and Eva version
Environment information
The text was updated successfully, but these errors were encountered: