-
-
Notifications
You must be signed in to change notification settings - Fork 598
refact: remove mixed CJS/ESM, refactorize index.native.tsx #1982
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
Conversation
WoLewicki
left a comment
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 good 🚀 I left some comments.
| ...props | ||
| } = rest; | ||
|
|
||
| if (active !== undefined && activityState === 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.
I think we will remove the active prop and code related to it in v4, just a note for future.
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.
Great, thanks for mentioning that. We can do that in a separate PR 👍
kkafar
left a comment
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.
Took a quick look now:
- I like that each component lives in its dedicated source file now <3
- Is there any advantage of converting every function to arrow function?
- We need to make sure that there are no more similar issues to the one we debugged last week (component exported under different name after the refactor)
|
…inc#5239) [](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [react-native-screens](https://togithub.com/software-mansion/react-native-screens) | [`^3.29.0` -> `^3.30.1`](https://renovatebot.com/diffs/npm/react-native-screens/3.29.0/3.30.1) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>software-mansion/react-native-screens (react-native-screens)</summary> ### [`v3.30.1`](https://togithub.com/software-mansion/react-native-screens/releases/tag/3.30.1) [Compare Source](https://togithub.com/software-mansion/react-native-screens/compare/3.30.0...3.30.1) Patch release addressing an issue with building a package due to the missing submodule from `postinstall` command. #### 🔢 Miscellaneous - Remove postinstall step from package.json by [@​tboba](https://togithub.com/tboba) in [https://github.com/software-mansion/react-native-screens/pull/2081](https://togithub.com/software-mansion/react-native-screens/pull/2081) **Full Changelog**: software-mansion/react-native-screens@3.30.0...3.30.1 ### [`v3.30.0`](https://togithub.com/software-mansion/react-native-screens/releases/tag/3.30.0) [Compare Source](https://togithub.com/software-mansion/react-native-screens/compare/3.29.0...3.30.0) Minor release including custom screen transitions, adding support for VisionOS, supporting `slide_from_left` animation on iOS and fixing other aspects (including wrong targets for touchable components on Fabric). Thanks for following along! 💙 **Note**: Please note that support for React Native versions lower than 0.68 have been **dropped**. Older versions may still continue to work with this and newer releases of react-native-screens, but bugs from deprecated versions will not be considered for repair. #### What's Changed #### 👍 Improvements - **Custom screen transitions** - In 3.30.0, we've introduced a support for custom transition animations while making a "go back" gesture. Made by [@​piaskowyk](https://togithub.com/piaskowyk) and [@​WoLewicki](https://togithub.com/WoLewicki) in [https://github.com/software-mansion/react-native-screens/pull/1913](https://togithub.com/software-mansion/react-native-screens/pull/1913) - **Support for VisionOS is here!** - From now, react-native-screens offers bundled support for VisionOS platform. Made by [@​okwasniewski](https://togithub.com/okwasniewski) in [https://github.com/software-mansion/react-native-screens/pull/2025](https://togithub.com/software-mansion/react-native-screens/pull/2025) - **`slide_from_left` transition on iOS** - You can use `slide_from_left` animation that will be used for pushing or popping a new screen. Made by [@​kirillzyusko](https://togithub.com/kirillzyusko) in [https://github.com/software-mansion/react-native-screens/pull/2057](https://togithub.com/software-mansion/react-native-screens/pull/2057) - Add `cancelSearch` command on SearchBar by [@​Jasonzj](https://togithub.com/Jasonzj) in [https://github.com/software-mansion/react-native-screens/pull/1987](https://togithub.com/software-mansion/react-native-screens/pull/1987) - Fixed Android screen stack animation by [@​janicduplessis](https://togithub.com/janicduplessis) in [https://github.com/software-mansion/react-native-screens/pull/2019](https://togithub.com/software-mansion/react-native-screens/pull/2019) #### 🐛 Bug fixes - Not working hitslop for headerRight/Left views by [@​kkafar](https://togithub.com/kkafar) in [https://github.com/software-mansion/react-native-screens/pull/1995](https://togithub.com/software-mansion/react-native-screens/pull/1995) - App freeze when navigating back from any modal nested in contained modal by [@​kkafar](https://togithub.com/kkafar) in [https://github.com/software-mansion/react-native-screens/pull/1996](https://togithub.com/software-mansion/react-native-screens/pull/1996) - Incorrect safe area on transparent modals using landscape orientation by [@​tboba](https://togithub.com/tboba) in [https://github.com/software-mansion/react-native-screens/pull/2008](https://togithub.com/software-mansion/react-native-screens/pull/2008) - Invalid orientation of contained modals by [@​tboba](https://togithub.com/tboba) in [https://github.com/software-mansion/react-native-screens/pull/2011](https://togithub.com/software-mansion/react-native-screens/pull/2011) - Modify the decorFitsSystemWindow parameter in setNavigationBarHidden by [@​jiyong1](https://togithub.com/jiyong1) in [https://github.com/software-mansion/react-native-screens/pull/1988](https://togithub.com/software-mansion/react-native-screens/pull/1988) - Avoid race condition related to state on the new arch by [@​j-piasecki](https://togithub.com/j-piasecki) in [https://github.com/software-mansion/react-native-screens/pull/2024](https://togithub.com/software-mansion/react-native-screens/pull/2024) - Check for multiple screens while changing screen orientation by [@​uzegonemad](https://togithub.com/uzegonemad) in [https://github.com/software-mansion/react-native-screens/pull/2035](https://togithub.com/software-mansion/react-native-screens/pull/2035) - Fix setting incorrect measure with native header by [@​WoLewicki](https://togithub.com/WoLewicki) and [@​tboba](https://togithub.com/tboba) in [https://github.com/software-mansion/react-native-screens/pull/2028](https://togithub.com/software-mansion/react-native-screens/pull/2028) - Add notifying for header height change, fix header height values by [@​tboba](https://togithub.com/tboba) in [https://github.com/software-mansion/react-native-screens/pull/2075](https://togithub.com/software-mansion/react-native-screens/pull/2075) - Change context while running `runOnUiQueueThread` on 0.73 with Bridgeless by [@​cortinico](https://togithub.com/cortinico) in [https://github.com/software-mansion/react-native-screens/pull/2022](https://togithub.com/software-mansion/react-native-screens/pull/2022) - Use reactApplicationContext in onScreenChanged by [@​WoLewicki](https://togithub.com/WoLewicki) in [https://github.com/software-mansion/react-native-screens/pull/2046](https://togithub.com/software-mansion/react-native-screens/pull/2046) - Remove calculating status bar height in useAnimatedHeaderHeight when header is not shown by [@​tboba](https://togithub.com/tboba) in [https://github.com/software-mansion/react-native-screens/pull/2033](https://togithub.com/software-mansion/react-native-screens/pull/2033) - Handle setting `display` for `_viewConfig` attribute by [@​WoLewicki](https://togithub.com/WoLewicki) and [@​tboba](https://togithub.com/tboba) in [https://github.com/software-mansion/react-native-screens/pull/2071](https://togithub.com/software-mansion/react-native-screens/pull/2071) - Fix crash with searchResultsController in RNSSearchBar by [@​tboba](https://togithub.com/tboba) in [https://github.com/software-mansion/react-native-screens/pull/2004](https://togithub.com/software-mansion/react-native-screens/pull/2004) - Add constraints for velocity in `goBackGesture` screen transition by [@​piaskowyk](https://togithub.com/piaskowyk) in [https://github.com/software-mansion/react-native-screens/pull/2061](https://togithub.com/software-mansion/react-native-screens/pull/2061) - Add view check for getting StackView in `goBackGesture` by [@​piaskowyk](https://togithub.com/piaskowyk) in [https://github.com/software-mansion/react-native-screens/pull/2060](https://togithub.com/software-mansion/react-native-screens/pull/2060) - Change default value of context of ScreenGestureDetector, add warning for goBackGesture by [@​tboba](https://togithub.com/tboba) in [https://github.com/software-mansion/react-native-screens/pull/2013](https://togithub.com/software-mansion/react-native-screens/pull/2013) - Move GHContext from gesture-handler to native-stack by [@​tboba](https://togithub.com/tboba) in [https://github.com/software-mansion/react-native-screens/pull/2017](https://togithub.com/software-mansion/react-native-screens/pull/2017) - Change default gesture from Tap to Fling, fix failing CI by [@​tboba](https://togithub.com/tboba) in [https://github.com/software-mansion/react-native-screens/pull/2023](https://togithub.com/software-mansion/react-native-screens/pull/2023) #### 🔢 Miscellaneous - **Drop React Native 0.64 - 0.67 since 3.30.0** by [@​tboba](https://togithub.com/tboba) in [https://github.com/software-mansion/react-native-screens/pull/2036](https://togithub.com/software-mansion/react-native-screens/pull/2036) - Remove mixed CJS/ESM, refactorize index.native.tsx by [@​tboba](https://togithub.com/tboba) in [https://github.com/software-mansion/react-native-screens/pull/1982](https://togithub.com/software-mansion/react-native-screens/pull/1982) - Add react-navigation as submodule & use it in test applications by [@​kkafar](https://togithub.com/kkafar) and [@​tboba](https://togithub.com/tboba) in [https://github.com/software-mansion/react-native-screens/pull/1993](https://togithub.com/software-mansion/react-native-screens/pull/1993) - Unify member-field naming convention in Kotlin by [@​kkafar](https://togithub.com/kkafar) in [https://github.com/software-mansion/react-native-screens/pull/1999](https://togithub.com/software-mansion/react-native-screens/pull/1999) - Update compatibility table with supported RN versions with Fabric by [@​kkafar](https://togithub.com/kkafar) in [https://github.com/software-mansion/react-native-screens/pull/2001](https://togithub.com/software-mansion/react-native-screens/pull/2001) - Change name of `headerBackButtonClicked` event by [@​WoLewicki](https://togithub.com/WoLewicki) in [https://github.com/software-mansion/react-native-screens/pull/2015](https://togithub.com/software-mansion/react-native-screens/pull/2015) - Stabilize Android E2E tests by [@​kirillzyusko](https://togithub.com/kirillzyusko) in [https://github.com/software-mansion/react-native-screens/pull/2062](https://togithub.com/software-mansion/react-native-screens/pull/2062) - Update Podfiles in Example projects, update RN in FabricExample to 0.73 by [@​tboba](https://togithub.com/tboba) in [https://github.com/software-mansion/react-native-screens/pull/1989](https://togithub.com/software-mansion/react-native-screens/pull/1989) - Update React Native to 0.73.4, change Cocoapods version by [@​tboba](https://togithub.com/tboba) in [https://github.com/software-mansion/react-native-screens/pull/2032](https://togithub.com/software-mansion/react-native-screens/pull/2032) - Configure yarn version in package.json by [@​bakkerjoeri](https://togithub.com/bakkerjoeri) in [https://github.com/software-mansion/react-native-screens/pull/2077](https://togithub.com/software-mansion/react-native-screens/pull/2077) - Bump ip from 1.1.8 to 1.1.9 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/software-mansion/react-native-screens/pull/2038](https://togithub.com/software-mansion/react-native-screens/pull/2038) - Bump ip from 1.1.8 to 1.1.9 in example apps by [@​tboba](https://togithub.com/tboba) in [https://github.com/software-mansion/react-native-screens/pull/2044](https://togithub.com/software-mansion/react-native-screens/pull/2044) #### New Contributors - [@​jiyong1](https://togithub.com/jiyong1) made their first contribution in [https://github.com/software-mansion/react-native-screens/pull/1988](https://togithub.com/software-mansion/react-native-screens/pull/1988) - [@​Jasonzj](https://togithub.com/Jasonzj) made their first contribution in [https://github.com/software-mansion/react-native-screens/pull/1987](https://togithub.com/software-mansion/react-native-screens/pull/1987) - [@​j-piasecki](https://togithub.com/j-piasecki) made their first contribution in [https://github.com/software-mansion/react-native-screens/pull/2024](https://togithub.com/software-mansion/react-native-screens/pull/2024) - [@​cortinico](https://togithub.com/cortinico) made their first contribution in [https://github.com/software-mansion/react-native-screens/pull/2022](https://togithub.com/software-mansion/react-native-screens/pull/2022) - [@​okwasniewski](https://togithub.com/okwasniewski) made their first contribution in [https://github.com/software-mansion/react-native-screens/pull/2025](https://togithub.com/software-mansion/react-native-screens/pull/2025) - [@​uzegonemad](https://togithub.com/uzegonemad) made their first contribution in [https://github.com/software-mansion/react-native-screens/pull/2035](https://togithub.com/software-mansion/react-native-screens/pull/2035) - [@​bakkerjoeri](https://togithub.com/bakkerjoeri) made their first contribution in [https://github.com/software-mansion/react-native-screens/pull/2077](https://togithub.com/software-mansion/react-native-screens/pull/2077) #### 🙌 Thank you for your contributions! **Full Changelog**: software-mansion/react-native-screens@3.29.0...3.30.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 5pm,every weekend" in timezone America/Los_Angeles, Automerge - "after 5pm,every weekend" in timezone America/Los_Angeles. 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/valora-inc/wallet). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNjkuMiIsInVwZGF0ZWRJblZlciI6IjM3LjI2OS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: valora-bot <[email protected]>
…mansion#1982) ## Description Users are reporting that on Vite they cannot build their project with react-native-screens because of the mixed CJS/ESM files that are being created while building a bundle (you can see [here](https://publint.dev/[email protected]) that some package managers reports errors about mixed CJS/ESM files). To reduce that behavior I've decided to remove CJS completely while bundling the project, resulting in building only ESM files. Unfortunately because of that I had to remove optional requiring process inside the index.native.tsx file, but this shouldn't have a large impact while using rn-screens. I also decided to move some parts of the screens implementation to separate files - this should improve readability, better understanding of code for newcomers and should improve developer experience overall. Having only imports and exports in index files is also a good practice - this was my main reason why I've planned to do that. Closes software-mansion#1908 - I'll try to ensure that this will fix Vite for sure 👍 ## Changes - Disable bundling CJS files from react-native-screens - Refactorize index.native.tsx files to separate files ## Test code and steps to reproduce First, try to bundle the project - you can see that inside `lib` there shouldn't be `common` directory with the CJS files. Then, try to run FabricTestExample with a couple of tests. Application should work properly as usual. ## Developer notes There are some points that I stumbled upon and I need to mention here. - I've managed to move all of the native components from class to function components, **except**: - **Screen:** Unfortunately we need to stay with class components there, as for now we would like to keep behavior of using `setNativeProps` for a screen (does anybody do that? Or is react-native calling this method for a screen wherever? There's a field for a discussion). - **SearchBar:** Because of managing ref's state and dropping it down to the methods responsible for commands I was also unable to convert this to functional component. - I tried to also refactor index.tsx file, but I see no reason to do this. For now I'm keeping it as it is (with only a slight changes to this file): - Because of a conflict of naming between SearchBarCommands (from types.tsx) and SearchBarCommands as a native component -> it's not that easy to fix, so I suggest fixing this in a future (might be also a good first issue). - I also tried to move `index.native.tsx` to `index.tsx` and to move `index.tsx` to `index.web.tsx`, but because of a conflict I described above and because I don't see the point of rendering conditionally native components depending if `Platform.OS !== 'web'` (and rendering a `View` if Platform.OS is web) I'm keeping the current naming. - Let me know what do you think about the refactor of index.native.tsx! This change is a **Proof of concept** and I codenamed it as a second stage of this PR, so we might give it a try, but I'm all ears about your opinion - IMO it is worth merging. ## Checklist - [X] Ensured that nothing changed while refactoring index.native.tsx - [X] Ensured that CI passes
Description
Users are reporting that on Vite they cannot build their project with react-native-screens because of the mixed CJS/ESM files that are being created while building a bundle (you can see here that some package managers reports errors about mixed CJS/ESM files). To reduce that behavior I've decided to remove CJS completely while bundling the project, resulting in building only ESM files. Unfortunately because of that I had to remove optional requiring process inside the index.native.tsx file, but this shouldn't have a large impact while using rn-screens.
I also decided to move some parts of the screens implementation to separate files - this should improve readability, better understanding of code for newcomers and should improve developer experience overall. Having only imports and exports in index files is also a good practice - this was my main reason why I've planned to do that.
Closes #1908 - I'll try to ensure that this will fix Vite for sure 👍
Changes
Test code and steps to reproduce
First, try to bundle the project - you can see that inside
libthere shouldn't becommondirectory with the CJS files.Then, try to run FabricTestExample with a couple of tests. Application should work properly as usual.
Developer notes
There are some points that I stumbled upon and I need to mention here.
I've managed to move all of the native components from class to function components, except:
setNativePropsfor a screen (does anybody do that? Or is react-native calling this method for a screen wherever? There's a field for a discussion).I tried to also refactor index.tsx file, but I see no reason to do this. For now I'm keeping it as it is (with only a slight changes to this file):
index.native.tsxtoindex.tsxand to moveindex.tsxtoindex.web.tsx, but because of a conflict I described above and because I don't see the point of rendering conditionally native components depending ifPlatform.OS !== 'web'(and rendering aViewif Platform.OS is web) I'm keeping the current naming.Let me know what do you think about the refactor of index.native.tsx! This change is a Proof of concept and I codenamed it as a second stage of this PR, so we might give it a try, but I'm all ears about your opinion - IMO it is worth merging
.
Checklist