Skip to content
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

Remove deprecated defaultProps #130

Open
moulie415 opened this issue Aug 8, 2024 · 2 comments
Open

Remove deprecated defaultProps #130

moulie415 opened this issue Aug 8, 2024 · 2 comments

Comments

@moulie415
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch react-native-user-avatar@1.0.8 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-user-avatar/src/index.js b/node_modules/react-native-user-avatar/src/index.js
index 170bad8..105c65b 100644
--- a/node_modules/react-native-user-avatar/src/index.js
+++ b/node_modules/react-native-user-avatar/src/index.js
@@ -17,18 +17,26 @@ import {
 
 const UserAvatar = (props) => {
   let {
-    name,
+    name = 'John Doe',
     src,
     bgColor,
-    bgColors,
-    textColor,
-    size,
+    bgColors =  [ // from https://flatuicolors.com/
+      '#2ecc71', // emerald
+      '#3498db', // peter river
+      '#8e44ad', // wisteria
+      '#e67e22', // carrot
+      '#e74c3c', // alizarin
+      '#1abc9c', // turquoise
+      '#2c3e50', // midnight blue
+    ],
+    textColor = '#fff',
+    size = 32,
     imageStyle,
     style,
     borderRadius,
     component,
     noUpperCase,
-    textStyle,
+    textStyle = {},
   } = props;
 
   // Validations
@@ -91,21 +99,7 @@ UserAvatar.propTypes = {
   textStyle: PropTypes.object,
 };
 
-UserAvatar.defaultProps = {
-  size: 32,
-  textColor: '#fff',
-  name: 'John Doe',
-  bgColors: [ // from https://flatuicolors.com/
-    '#2ecc71', // emerald
-    '#3498db', // peter river
-    '#8e44ad', // wisteria
-    '#e67e22', // carrot
-    '#e74c3c', // alizarin
-    '#1abc9c', // turquoise
-    '#2c3e50', // midnight blue
-  ],
-  textStyle: {},
-};
+
 
 export {generateBackgroundColor};
 

This issue body was partially generated by patch-package.

@richardhensman123
Copy link

+1

@bhavberi
Copy link

This project has not been maintained for some time and contains outdated dependencies. To address this, I created a fork of the project, updated various packages, and resolved several issues. The updated version has been published as a new package, which you can find here: @bhavberi/react-native-user-avatar. Replacing the old package with this one will help resolve these issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants