question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

integration with patch-package

See original GitHub issue

Current behaviour

Expected behaviour

I’m trying to apply the following patch:

diff --git a/node_modules/react-native-paper/src/components/Avatar/AvatarImage.tsx b/node_modules/react-native-paper/src/components/Avatar/AvatarImage.tsx
index 3b71389..a874e2b 100644
--- a/node_modules/react-native-paper/src/components/Avatar/AvatarImage.tsx
+++ b/node_modules/react-native-paper/src/components/Avatar/AvatarImage.tsx
@@ -58,6 +58,8 @@ const AvatarImage = ({
   source,
   style,
   theme,
+  onError,
+  onLoad,
   ...rest
 }: Props) => {
   const { colors } = theme;
@@ -82,6 +84,8 @@ const AvatarImage = ({
         <Image
           source={source}
           style={{ width: size, height: size, borderRadius: size / 2 }}
+          onError={onError}
+          onLoad={onLoad}
         />
       )}
     </View>
diff --git a/node_modules/react-native-paper/src/components/Drawer/DrawerItem.tsx b/node_modules/react-native-paper/src/components/Drawer/DrawerItem.tsx
index 503cfab..cd3933d 100644
--- a/node_modules/react-native-paper/src/components/Drawer/DrawerItem.tsx
+++ b/node_modules/react-native-paper/src/components/Drawer/DrawerItem.tsx
@@ -5,6 +5,7 @@ import Text from '../Typography/Text';
 import Icon, { IconSource } from '../Icon';
 import TouchableRipple from '../TouchableRipple/TouchableRipple';
 import { withTheme } from '../../core/theming';
+import Badge from '../Badge';
 
 type Props = React.ComponentPropsWithRef<typeof View> & {
   /**
@@ -67,6 +68,7 @@ const DrawerItem = ({
   style,
   onPress,
   accessibilityLabel,
+  badge,
   ...rest
 }: Props) => {
   const { colors, roundness } = theme;
@@ -100,22 +102,25 @@ const DrawerItem = ({
         accessibilityState={{ selected: active }}
         accessibilityLabel={accessibilityLabel}
       >
-        <View style={styles.wrapper}>
-          {icon ? <Icon source={icon} size={24} color={contentColor} /> : null}
-          <Text
-            selectable={false}
-            numberOfLines={1}
-            style={[
-              styles.label,
-              {
-                color: contentColor,
-                ...font,
-                marginLeft: labelMargin,
-              },
-            ]}
-          >
-            {label}
-          </Text>
+        <View style={styles.badgeContainer}>
+          <View style={styles.wrapper}>
+            {icon ? <Icon source={icon} size={24} color={contentColor} /> : null}
+            <Text
+              selectable={false}
+              numberOfLines={1}
+              style={[
+                styles.label,
+                {
+                  color: contentColor,
+                  ...font,
+                  marginLeft: labelMargin,
+                },
+              ]}
+            >
+              I am patch-package
+            </Text>
+          </View>
+          {!isNaN(badge) ? <Badge visible={Boolean(badge)}>{badge}</Badge> : null}
         </View>
       </TouchableRipple>
     </View>
@@ -131,12 +136,17 @@ const styles = StyleSheet.create({
   },
   wrapper: {
     flexDirection: 'row',
-    alignItems: 'center',
-    padding: 8,
+    alignItems: 'center'
   },
   label: {
     marginRight: 32,
   },
+  badgeContainer: {
+    flexDirection: 'row',
+    justifyContent: 'space-between',
+    alignItems: 'center',
+    padding: 8,
+  },
 });
 
 export default withTheme(DrawerItem);

These are some of my custom changes, it seems to work when running my app locally on my device, but when I deploy it to production, I don’t see my patches being applied, I even put I am patch-package there in purpose just to see, but it didn’t work.

I’m running the build and deploy using this bash script

export STAGE="<hidden value>"
export API_BASE_URL="<hidden value>"
export APPLE_ID="<hidden value>"
export APPSTORE_ISSUER_ID="<hidden value>"
export APPSTORE_KEY_ID="<hidden value>"
export APPSTORE_TEAM_ID="<hidden value>"
export MATCH_GIT_BASIC_AUTHORIZATION="<hidden value>"
export MATCH_PASSWORD="<hidden value>"
export MATCH_REPO="<hidden value>"

rm -rf ios-build
git clone <hidden value>.git ios-build
cp FastlaneDeploymentCI.p8 ios-build/ios/FastlaneDeploymentCI.p8
cp GoogleService-Info.plist ios-build/ios/my-app/GoogleService-Info.plist
cd ios-build
cp src/env.example.js src/env.js
bundle
yarn --prefer-offline
cd ios
NODE_ENV=production pod install
yarn patch-package
bundle exec fastlane ios preprod
cd ../../
rm -rf ios-build

As you can see, I’m already manually running the yarn patch-package command, plus on my package.json, I have "postinstall": "husky install && patch-package", but I manually ran patch-package while debugging because I’m trying to figure out why it’s happening, he only reason I can see is because there’s src and lib. It could be that when building for production, the metro bundler is looking at lib instead of src, but all my patches are in src not in lib because the lib is built, that would mean I will have to build react-native-paper locally but I can’t because I don’t think the files I get are complete, bob build fails when I try it out.

Code sample

N/A

Screenshots (if applicable)

N/A

What have you tried

N/A

Your Environment

software version
ios or android
react-native
react-native-paper
node
npm or yarn
expo sdk

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
github-actions[bot]commented, Apr 4, 2021

Couldn’t find version numbers for the following packages in the issue:

  • react-native
  • react-native-paper
  • react-native-vector-icons
  • yarn
  • npm
  • expo

Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ds300/patch-package: Fix broken node modules instantly ‍♀️
patch -package lets app authors instantly make and keep fixes to npm dependencies. It's a vital band-aid for those of us living on...
Read more >
Patch Package - KPITENG
patch -package allow developers to update code in node_modules with still keeping your changes even after upgrading/downgrading your node_modules ...
Read more >
Hot-patching our dependencies with patch-package
About patch-package · yarn / npm lock the dependency on that specific version so our entire team and the build pipeline gets the...
Read more >
The easiest way to patch your npm package when there is a
The easiest way to patch your npm package when there is a · The easiest way and actually most devs do, is go...
Read more >
How to Patch NPM Packages - Mobile App Development ...
Let's re-install redux and see if the patch-package applies our changes which are created as a patch in the patches folder. Run following...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found