react-native-app-intro-slider icon indicating copy to clipboard operation
react-native-app-intro-slider copied to clipboard

delays in rendering a page for appintroslider when app is first opened in version 4.0.4

Open nketia opened this issue 4 years ago • 3 comments

I upgraded the package to the current version 4.0.4 from 2.0.1 and this seems to be causing delays when rendering for the first time. Navigating to the page for appintroslider drags for about 5 seconds before it opens. This used not to be the case and behaves normally when I downgrade to the 2.0.1

nketia avatar Mar 23 '21 16:03 nketia

after delving into the source code, i saw

// index.js
this.state = {
      width: 0,
      height: 0,
      activeIndex: 0,
  };

i change this value width and height to

// Dimensions is from react-native
this.state = {
            width: Dimensions.get('screen').width,
            height: Dimensions.get('screen').height,
            activeIndex: 0,
        };

so the slider wont have width 0 at first (before, seemingly there is no slide at first)

is that what you mean with render time? this is what i meant

hkar19 avatar Mar 31 '21 00:03 hkar19

I faced the same issue and patched by setting the width and height using Dimensions. Otherwise your slides can may "glitch" initially before the onLayout event is called on the FlatList.

davidstott avatar Aug 21 '21 09:08 davidstott

For those still encountering this issue, here's the patch solution:

react-native-app-intro-slider+4.0.4.patch

diff --git a/node_modules/react-native-app-intro-slider/dist/index.js b/node_modules/react-native-app-intro-slider/dist/index.js
index 0935c97..9ca160e 100644
--- a/node_modules/react-native-app-intro-slider/dist/index.js
+++ b/node_modules/react-native-app-intro-slider/dist/index.js
@@ -18,8 +18,8 @@ class AppIntroSlider extends React.Component {
     constructor() {
         super(...arguments);
         this.state = {
-            width: 0,
-            height: 0,
+            width: react_native_1.Dimensions.get('screen').width,
+            height: react_native_1.Dimensions.get('screen').height,
             activeIndex: 0,
         };
         this.goToSlide = (pageNum, triggerOnSlideChange) => {

For help using this patch or with the patch-package dependency, refer to this link https://github.com/Kureev/react-native-blur/issues/444#issuecomment-919359370

Raymond-Cox avatar Feb 25 '22 15:02 Raymond-Cox