-
Notifications
You must be signed in to change notification settings - Fork 11
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
chore(exoflex): update react
, react-native
& react-native-paper
version
#713
chore(exoflex): update react
, react-native
& react-native-paper
version
#713
Conversation
e1722b9
to
538739c
Compare
[Chores][Fix] Update RN calendars
…ts-error [Chores][Fix] Update RN calendars
aa66095
to
69a8904
Compare
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.
Thanks for upgrading all of these. The changes looks good but I've several suggestion and question. We also might need @darcien help to review these too, since I'm not super familiar with exoflex
"react-native-animation-hooks": "^1.0.1", | ||
"react-native-calendars": "https://github.com/oshimayoan/react-native-calendars/archive/oshimayoan-0.0.3.tar.gz", | ||
"react-native-collapsible": "^1.5.1", | ||
"react-native-calendars": "^1.1293.0", |
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.
On reverting this to the newest feat, have we test these change support what Yoan originally patch out?
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's already supported on the newest version, but let me include @JonathanRadotski to the discussion. What do you think?
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.
Briefly checked and comparing added feature. I think the newest version is already supported with added feature from previous package and good to go 👍.
diff --git a/node_modules/react-navigation-drawer/lib/module/views/Drawer.js b/node_modules/react-navigation-drawer/lib/module/views/Drawer.js | ||
index 3f81450..cf976b7 100644 | ||
--- a/node_modules/react-navigation-drawer/lib/module/views/Drawer.js | ||
+++ b/node_modules/react-navigation-drawer/lib/module/views/Drawer.js |
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.
After checking the issue, from my understanding it seems this was caused by we using react-navigation 4. It's not required to do this now but I think it's good to also upgrade it to react-navigation 5/6.
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.
If the upgrade is not a 5 mins job, lets just land this first and upgrade on separate PR
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.
Got it, will try and report later.
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.
Based on this: https://reactnavigation.org/docs/5.x/upgrading-from-4.x#navigation-container
I thinks it's better to upgrade on separate PR, since we still using createAppContainer
to wrap our RootNavigator
.
: !!renderIconRight | ||
? renderIconRight(animatedValue) | ||
: DefaultIcon} | ||
<> |
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've checked out these changes and it seems now will throw error when we use more than one child. Is this supposed to work like that? or is it possible we messed up with something? React native doc say View is designed to be nested inside other views and can have 0 to many children of any type.
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.
Might be something from the collapsible package we use which attach a gesture handler to the children, requiring specifically only 1 child. Need investigation as I don't remember the detail here.
@StefanusChristian Also do we have the example of buttonRipple not working properly on the IOS? curious what's the actual result of these bug |
diff --git a/node_modules/react-navigation-drawer/lib/module/views/Drawer.js b/node_modules/react-navigation-drawer/lib/module/views/Drawer.js | ||
index 3f81450..cf976b7 100644 | ||
--- a/node_modules/react-navigation-drawer/lib/module/views/Drawer.js | ||
+++ b/node_modules/react-navigation-drawer/lib/module/views/Drawer.js |
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.
If the upgrade is not a 5 mins job, lets just land this first and upgrade on separate PR
@@ -38,19 +39,18 @@ export default function ButtonOpacity(props: ButtonProps) { | |||
return ( | |||
<TouchableOpacity | |||
{...otherProps} | |||
ref={ref as RefObject<TouchableOpacity>} |
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'm not sure if passing ref
directly will work or not.
This will need a bit of testing and see if this needs use forwardRef instead.
For now I think this is OK, just make sure to not release this before testing whether the ref works or not.
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.
Got it, will test it.
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.
About this problem, I think I'll open up a discussion in here. So the initial reason why I add this change was because the parent exoflex Button
component has props with type ButtonProps
which inherit PaperButton
types.
PaperButton
props type also inherit PaperSurface
type, which has the ref
prop with type React.RefObject<View>
Our exoflex Button has 2 type: ButtonOpacity
& ButtonRipple
, which will rendered based on useRipple
props.
With ButtonRipple
, which will render TouchableRipple
from react-native-paper
, it seems the passed <React.RefObject<View>>
ref
from ButtonProps
didn't raise any type error. Turns out TouchableRipple
inherits its prop type from RN Pressable
and also has the forwardedRef - React.RefAttributes<View>
.
But with ButtonOpacity
, which will render TouchableOpacity
from react-native
, it raises ref
type error. Because the desired type was LegacyRef<TouchableOpacity>
but supplied with RefObject<View>
. That's why I passing the ref like that and typecast it as RefObject<TouchableOpacity>
to fulfilled the required type.
As for using the forwardRef
, the same problem arise when I need to type the ref
from using forwardRef
on Parent Button component.
Maybe you guys can enlighten me on how to solve this problem?
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.
It's been a while since I worked on this area, so it might be a bit hard to give exact code solution.
From a glance, we should be able to resolve this type conflict by migrating away from TouchableOpacity and use Pressable instead. That way the ref is always a View ref.
The cons: we need to mimic the old TouchableOpacity using Pressable to keep the same behavior. Unless we want to change the default button behavior, and just do a breaking changes.
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.
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.
Looks great 👍
You might want to put the animated value in a ref and memoize the fade transition functions for optimizations.
Also, probably it's not a good idea to override the onPressIn/onPressOut from other props with our fade animation. Will need to extend it so we also call the onPressIn/onPressOut from the props.
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.
Got it! Applied in here: 4971cb9
: !!renderIconRight | ||
? renderIconRight(animatedValue) | ||
: DefaultIcon} | ||
<> |
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.
Might be something from the collapsible package we use which attach a gesture handler to the children, requiring specifically only 1 child. Need investigation as I don't remember the detail here.
Great work @StefanusChristian! We might need to update the repo settings before merging your changes because right now it's blocked by a dead circleci check. |
Let's not block the upgrade PR on the button ripple issue. I'm keen to ship this B I G P R ASAP and address the minor issues separately. |
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.
note on the memo dependency issue
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); |
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.
Let's not disable this lint rule and fix the warning.
Not setting the dependency for useCallback correctly might cause subtle bugs with stale values.
Actually, let's do optimization separately now that I think about it. See my next comment.
onPressIn={(e) => { | ||
onPressIn && onPressIn(e); | ||
fadeOpacityIn(); | ||
}} |
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.
Here, we create another arrow function inline, which is the thing we want to optimize before by moving the arrow function to useCallback.
If you want a deep dive on this, beta docs from React is a good starting point, like: https://beta.reactjs.org/reference/react/useCallback#should-you-add-usecallback-everywhere
But in the meantime, let's just keep the fix in and iterate on the optimization later.
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.
Got it, will do.
For the repo setting (remove/bypass the circleci check), do you have the authority for that @darcien? I think I don't have the permission, so I can't adjust the setting
I've removed the required CircleCI check for merging the PR. @StefanusChristian can you try running the tests locally and see if it passes? |
It seems the jest preset is error for Do you guys have any idea on how to fix the |
@ikusa @darcien Passed TestsPassed.exoflex.test.mp4I'll list the changes for making the web test work in here:
From:
fireEvent.click(getByTestId('button'));
Into:
fireEvent(
getByTestId('button'),
new MouseEvent('click', {
bubbles: true,
cancelable: true,
}),
); |
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.
Let's merge this
Changes:
Package & Example app changes:
react
,react-native
,react-native-web
,react-native-paper
,react-native-collapsible
version.react-native-calendars
from Yoan repository into latest version. (changes from @JonathanRadotski https://github.com/StefanusChristian/infra/pull/1/files)example
directory. Since the previous one was still in SDK40, it is easier to create a new one instead of updating it to SDK47.patch-package
to bothexoflex
(patchreact-native-collapsible
) &exoflex/new-example
(patchreact-navigation-drawer
).react-native-collapsible
: Adding the fix that has been merged to the package but not released yet. commitreact-navigation-drawer
: This package is deprecated now and have been included intoreact-navigation
instead. But I think it was introduced in version5.x.x
(docs) and we still use4.x.x
(docs). So for a quick fix, I follow this guide for the error: TypeError: interpolate is not a function react-navigation/react-navigation#9665 (comment)Adjusted Component:
Accordion
: AdduseNativeRiver
props touseAnimation()
Badge
: AddtextStyle
typingButton
:ButtonOpacity
:RefObject<TouchableOpacity>
sinceButtonProp
types based onreact-native-paper
types and the ref wasRefObject<View>
(from Surface component).accessibilityTraits
&accessibilityComponentType
intoaccessibilityStates
. (Reference)Icon
props naming fromcolor
toiconColor
.ButtonRipple
:accessibilityTraits
&accessibilityComponentType
intoaccessibilityStates
.Icon
props naming fromcolor
toiconColor
.Calendar
: AdjustCalendarProps
to follow latest version of the package.Chip
: AdjustIcon
props naming fromcolor
toiconColor
.Collapsible
: AdduseNativeRiver
props touseAnimation()
DateTimePicker
: AdjustDateTimePicker.web
type fromDateObject
intoDateData
.Menu
: AdjustPaperMenu.Item
props naming fromicon
toleadingIcon
.SegmentedControl
: AddStyleProp<ViewStyle>
in bothIndicator
&SegmentedControl
.Switch
: AddStyleProp<ViewStyle>
types.Toast
: AdjustIcon
props naming fromcolor
toiconColor
.Contants, Helper & Types Changes:
Theme
: Add 2 new color key as part of the Theme:notification
&tooltip
.getPaperTheme
: Adjust import naming fromTheme
intoMD2Theme
and adjust the props needed.Colors
types: Add new keytooltip
as Colors type.react-native-color-slider
types: Changenumber[]
intoArray<number>
How to test:
packages/exoflex
and runyarn install
to install dependencies.packages/exoflex/example
and also runyarn install
. Once it's done, runyarn start
to test the component.Notes:
Based on testing, the only component that has problem is
ButtonRipple
. The button didn't work properly on iOS simulator, but animation run properly on Android (cc: @JonathanRadotski @Udayawibawamukti).