r3tr0c0d3r / rn-slide-button

Slide Button (Swipe Button) component for react native
MIT License
13 stars 16 forks source link

Issue with React v18.2.0 #8

Open walker007 opened 5 months ago

walker007 commented 5 months ago

Hi! ๐Ÿ‘‹

Firstly, thanks for your work on this project! ๐Ÿ™‚

Today I used patch-package to patch rn-slide-button@1.0.3 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/rn-slide-button/src/components/SlideButton.tsx b/node_modules/rn-slide-button/src/components/SlideButton.tsx
index 20d55f6..e646adf 100644
--- a/node_modules/rn-slide-button/src/components/SlideButton.tsx
+++ b/node_modules/rn-slide-button/src/components/SlideButton.tsx
@@ -83,29 +83,29 @@ export type SlideButtonCommonProps = {

 const SlideButton = ({
   width,
-  height,
-  borderRadius,
-  completeThreshold,
-  disabled,
-  padding,
-  title,
+  height= DEFAULT_HEIGHT,
+  borderRadius= DEFAULT_BORDER_RADIUS,
+  completeThreshold= DEFAULT_COMPLETE_THRESHOLD,
+  disabled=false,
+  padding= DEFAULT_CONTAINER_PADDING,
+  title= DEFAULT_TITLE,
   titleContainerStyle,
   titleStyle,
   icon,
   thumbStyle,
   containerStyle,
   underlayStyle,
-  onReachedToStart,
-  onReachedToEnd,
-  onSlideEnd,
-  onSlideStart,
-  reverseSlideEnabled,
-  autoReset,
-  autoResetDelay,
-  animation,
-  animationDuration,
-  dynamicResetEnabled,
-  dynamicResetDelaying,
+  onSlideStart= () => {},
+  onSlideEnd= () => {},
+  onReachedToStart= () => {},
+  onReachedToEnd=() => {},
+  reverseSlideEnabled= true,
+  autoReset= DEFAULT_AUTO_RESET,
+  autoResetDelay= DEFAULT_AUTO_RESET_DELAY,
+  animation= DEFAULT_ANIMATION,
+  animationDuration= DEFAULT_ANIMATION_DURATION,
+  dynamicResetEnabled= false,
+  dynamicResetDelaying= false,
 }: SlideButtonProps) => {
   const [dimensions, setDimensions] = React.useState({ width: 0, height: 0 });
   const [endReached, setEndReached] = React.useState<boolean>(false);
@@ -346,26 +346,6 @@ const SlideButton = ({

 export default React.memo(SlideButton);

-SlideButton.defaultProps = {
-  height: DEFAULT_HEIGHT,
-  borderRadius: DEFAULT_BORDER_RADIUS,
-  padding: DEFAULT_CONTAINER_PADDING,
-  title: DEFAULT_TITLE,
-  completeThreshold: DEFAULT_COMPLETE_THRESHOLD,
-  disabled: false,
-  reverseSlideEnabled: true,
-  autoReset: DEFAULT_AUTO_RESET,
-  autoResetDelay: DEFAULT_AUTO_RESET_DELAY,
-  animation: DEFAULT_ANIMATION,
-  animationDuration: DEFAULT_ANIMATION_DURATION,
-  dynamicResetEnabled: false,
-  dynamicResetDelaying: false,
-  onSlideStart: () => {},
-  onSlideEnd: () => {},
-  onReachedToStart: () => {},
-  onReachedToEnd: () => {},
-};
-
 const styles = StyleSheet.create({
   container: {
     backgroundColor: DEFAULT_CONTAINER_COLOR,

This issue body was partially generated by patch-package.

alexisnsns commented 4 months ago

Hi! ๐Ÿ‘‹

Firstly, thanks for your work on this project! ๐Ÿ™‚

Today I used patch-package to patch rn-slide-button@1.0.3 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/rn-slide-button/src/components/SlideButton.tsx b/node_modules/rn-slide-button/src/components/SlideButton.tsx
index 20d55f6..e646adf 100644
--- a/node_modules/rn-slide-button/src/components/SlideButton.tsx
+++ b/node_modules/rn-slide-button/src/components/SlideButton.tsx
@@ -83,29 +83,29 @@ export type SlideButtonCommonProps = {

 const SlideButton = ({
   width,
-  height,
-  borderRadius,
-  completeThreshold,
-  disabled,
-  padding,
-  title,
+  height= DEFAULT_HEIGHT,
+  borderRadius= DEFAULT_BORDER_RADIUS,
+  completeThreshold= DEFAULT_COMPLETE_THRESHOLD,
+  disabled=false,
+  padding= DEFAULT_CONTAINER_PADDING,
+  title= DEFAULT_TITLE,
   titleContainerStyle,
   titleStyle,
   icon,
   thumbStyle,
   containerStyle,
   underlayStyle,
-  onReachedToStart,
-  onReachedToEnd,
-  onSlideEnd,
-  onSlideStart,
-  reverseSlideEnabled,
-  autoReset,
-  autoResetDelay,
-  animation,
-  animationDuration,
-  dynamicResetEnabled,
-  dynamicResetDelaying,
+  onSlideStart= () => {},
+  onSlideEnd= () => {},
+  onReachedToStart= () => {},
+  onReachedToEnd=() => {},
+  reverseSlideEnabled= true,
+  autoReset= DEFAULT_AUTO_RESET,
+  autoResetDelay= DEFAULT_AUTO_RESET_DELAY,
+  animation= DEFAULT_ANIMATION,
+  animationDuration= DEFAULT_ANIMATION_DURATION,
+  dynamicResetEnabled= false,
+  dynamicResetDelaying= false,
 }: SlideButtonProps) => {
   const [dimensions, setDimensions] = React.useState({ width: 0, height: 0 });
   const [endReached, setEndReached] = React.useState<boolean>(false);
@@ -346,26 +346,6 @@ const SlideButton = ({

 export default React.memo(SlideButton);

-SlideButton.defaultProps = {
-  height: DEFAULT_HEIGHT,
-  borderRadius: DEFAULT_BORDER_RADIUS,
-  padding: DEFAULT_CONTAINER_PADDING,
-  title: DEFAULT_TITLE,
-  completeThreshold: DEFAULT_COMPLETE_THRESHOLD,
-  disabled: false,
-  reverseSlideEnabled: true,
-  autoReset: DEFAULT_AUTO_RESET,
-  autoResetDelay: DEFAULT_AUTO_RESET_DELAY,
-  animation: DEFAULT_ANIMATION,
-  animationDuration: DEFAULT_ANIMATION_DURATION,
-  dynamicResetEnabled: false,
-  dynamicResetDelaying: false,
-  onSlideStart: () => {},
-  onSlideEnd: () => {},
-  onReachedToStart: () => {},
-  onReachedToEnd: () => {},
-};
-
 const styles = StyleSheet.create({
   container: {
     backgroundColor: DEFAULT_CONTAINER_COLOR,

This issue body was partially generated by patch-package.

This solution works fine ๐Ÿ‘