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

reRender #377

Open
jackimatin opened this issue Dec 25, 2021 · 5 comments
Open

reRender #377

jackimatin opened this issue Dec 25, 2021 · 5 comments

Comments

@jackimatin
Copy link

hi I have a question
how can I force swiper to reRender?

(I change my state that I use for swiper data but it does not reRender)

@truongbit
Copy link

I also had the same problem as you. Have you fixed it yet?

@abhilashiic
Copy link

abhilashiic commented Jan 28, 2022

same problem here!!

when I change the card-data, it does not get re-render

@ghost
Copy link

ghost commented Jun 8, 2022

same issue here,
any updates for this issue?

@mickaelcornelli
Copy link

mickaelcornelli commented Jul 25, 2022

You can check a similar issue here :

#153

You can pass a function in param from the parent to the child to render again the component like :

PARENT COMPONENT

import SwiperChild from "../SwiperChild"
const ParentComponent = (props) => {

const refresh = () =>{
     // here your code to refresh 
}

   return (
    <SwiperChild
                      index={index}
                      data={your data}
                      onRefresh={refresh}
   />
   )
}
export default ParentComponent 

CHILD

import Swiper from "react-native-deck-swiper";
import { Text, TouchableOpacity} from 'react-native'
const SwiperChild = ({ index, data, onRefresh }) => {
   return(
      <Swiper 
      cardIndex={index}
      cards={data}
      renderCard={(card, index) =>
      // An example to refresh
      <TouchableOpacity 
          onPress={()=>{
           // Call onRefresh here
          }}
       >
       <Text>REFRESH</Text>
      </TouchableOpacity>
      }
      />
   )
}
export default SwiperChild

Well, this is a rapid example , there is more complex swiper component but i hope u 'll understand the way to render again your component

@TheDevelolper
Copy link

I need to be able to re-render swiper in a react component so that I can change the effect based on screen size.

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

5 participants