Migrated Switch to function component syntax#23857
Conversation
| </PressableWithFeedback> | ||
| ); | ||
| } | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps |
There was a problem hiding this comment.
offsetX will remain constant, so I disabled the lint rule. Please let me know if we want to re-enable it and do other logic checks to avoid lint warnings.
| this.toggleSwitch(); | ||
| } | ||
| function Switch(props) { | ||
| const offsetX = useRef(new Animated.Value(props.isOn ? OFFSET_X.ON : OFFSET_X.OFF)).current; |
There was a problem hiding this comment.
Both state and ref will work the same, since we are only setting offsetX on mount. Please let me know if we want to use state here, instead of ref (my previous commit was using state)
| this.toggleSwitch(); | ||
| } | ||
| function Switch(props) { | ||
| const offsetX = useRef(new Animated.Value(props.isOn ? OFFSET_X.ON : OFFSET_X.OFF)).current; |
There was a problem hiding this comment.
| const offsetX = useRef(new Animated.Value(props.isOn ? OFFSET_X.ON : OFFSET_X.OFF)).current; | |
| const offsetX = useRef(new Animated.Value(props.isOn ? OFFSET_X.ON : OFFSET_X.OFF)); |
Is there any reason to define this as the current ref value? If not please apply the suggested change, this is helpful to avoid the useEffect extra dependencies (or lint disable rules)
| ); | ||
| } | ||
|
|
||
| Switch.propTypes = propTypes; |
| hoverDimmingValue={1} | ||
| pressDimmingValue={0.8} | ||
| > | ||
| <Animated.View style={[styles.switchThumb, {transform: [{translateX: offsetX}]}]} /> |
There was a problem hiding this comment.
No inline styles. Please write a functional style that accepts offsetX as a parameter.
There was a problem hiding this comment.
This is still not done. What I meant is to write a function that returns a style like textInputLabelTransformation or floatingMessageCounterTransformation.
|
@s77rt Thanks for the feedback. Applied the changes! |
Reviewer Checklist
Screenshots/VideosWebweb.mp4Mobile Web - Chromemweb-chrome.mp4Mobile Web - Safarimweb-safari.mp4Desktopdesktop.mp4iOSios.mp4Androidandroid.mp4 |
deetergp
left a comment
There was a problem hiding this comment.
Looks great, thanks for the changes!
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/deetergp in version: 1.3.49-0 🚀
|
|
🚀 Deployed to staging by https://github.com/deetergp in version: 1.3.50-0 🚀
|
|
🚀 Deployed to production by https://github.com/Beamanator in version: 1.3.49-3 🚀
|
|
🚀 Deployed to production by https://github.com/puneetlath in version: 1.3.50-3 🚀
|
Details
Fixed Issues
$ #16204
PROPOSAL: #16204 (comment)
Tests
Offline tests
Same as "Tests" section above
QA Steps
Same as "Tests" section above
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Web
Chrome
Web.Chrome.mp4
Safari
Web.Safari.mp4
Mobile Web - Chrome
mWeb.Chrome.mp4
Mobile Web - Safari
mWeb.Safari.mp4
Desktop
Desktop.mp4
iOS
IOS.Native.mp4
Android
Android.Native.mp4