-
-
Notifications
You must be signed in to change notification settings - Fork 259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(suite-native): make device switcher work without devicestate #15844
Conversation
🚀 Expo preview is ready!
|
e328856
to
b2c1b37
Compare
@@ -61,7 +61,7 @@ export const DeviceItemContent = React.memo( | |||
|
|||
const device = useSelectorDeepComparison((state: DeviceRootState) => { | |||
// select only what is needed to avoid unnecessary rerenders | |||
const d = selectDeviceByState(state, deviceState); | |||
const d = deviceState ? selectDeviceByState(state, deviceState) : undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
@@ -38,12 +38,13 @@ export const SimpleDeviceItemContent = React.memo( | |||
const { applyStyle } = useNativeStyles(); | |||
const deviceIsConnected = useSelector( | |||
// selecting only connected device property prevents unnecessary rerenders | |||
(state: DeviceRootState) => selectDeviceByState(state, deviceState)?.connected ?? null, | |||
(state: DeviceRootState) => | |||
deviceState ? selectDeviceByState(state, deviceState)?.connected : undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this make any difference? selectDeviceByState returns undefined anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it expects devicestate as defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this calls the selector in case deviceState is defined (expected by selectDeviceByState which I didnt want to change) or returns undefined otherwise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be fine to make selector to accept also undefined, WDYT? We will probably need it to use like this in more places no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that many places, actually. Right, it seems safe to change:
34f6539
to
92ffa07
Compare
Make device switcher to show content even in case there is no deviceState for the device.
Related Issue
Part of #15733