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

Fix rendering issue with old width / height and types definitions file #19

Open
amwebexpert opened this issue Nov 4, 2021 · 0 comments

Comments

@amwebexpert
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

  • usage of width and height as references to avoid memoizing old dimensions within the rest of the component logic
  • 1st version of a types.d.ts for those crasy devs (like us) using Typescript ;-)

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-gesture-flip-card/gestureFlipView.js b/node_modules/react-native-gesture-flip-card/gestureFlipView.js
index 8ea8ee2..418f4ca 100644
--- a/node_modules/react-native-gesture-flip-card/gestureFlipView.js
+++ b/node_modules/react-native-gesture-flip-card/gestureFlipView.js
@@ -1,16 +1,16 @@
-import React, { useState, useEffect, useRef, useImperativeHandle } from "react";
+import PropTypes from "prop-types";
+import React, { useEffect, useImperativeHandle, useRef, useState } from "react";
 import {
-  View,
   Animated,
   PanResponder,
   Platform,
-  StyleSheet,
+  StyleSheet, View
 } from "react-native";
-import PropTypes from "prop-types";
 
 const GestureFlipView = React.forwardRef((props, ref) => {
-  const width = Math.floor(props.width);
-  const height = Math.floor(props.height);
+  // Bug fix: using width and height as references avoid memoizing old dimensions within the rest of the component logic
+  const width = useRef(Math.floor(props.width)).current;
+  const height = useRef(Math.floor(props.height)).current;
   const [cardFace, setCardFace] = useState(true);
 
   const isAnimating = useRef(false);
diff --git a/node_modules/react-native-gesture-flip-card/index.d.ts b/node_modules/react-native-gesture-flip-card/index.d.ts
new file mode 100644
index 0000000..e4d03d9
--- /dev/null
+++ b/node_modules/react-native-gesture-flip-card/index.d.ts
@@ -0,0 +1,17 @@
+import * as React from 'react';
+import { ViewProps } from 'react-native';
+
+export type GestureFlipViewrops = {
+    width: number,
+    height: number,
+    perspective?: number,
+    gestureEnabled?: boolean,
+    onFlipEnd?: () => void,
+} & ViewProps;
+
+declare class GestureFlipView extends React.Component<GestureFlipViewrops, any> {
+    flipLeft: () => void;
+    flipRight: () => void;
+}
+
+export default GestureFlipView;

This issue body was partially generated by patch-package.

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

1 participant