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

Content of card does not render when state changed #85

Open
ErezBiren opened this issue Oct 16, 2022 · 2 comments
Open

Content of card does not render when state changed #85

ErezBiren opened this issue Oct 16, 2022 · 2 comments

Comments

@ErezBiren
Copy link

ErezBiren commented Oct 16, 2022

I did a simple example with TouchableOpacity that on press changes the count state from 1 to 2 and displays it as Text,
but the new value is not rerendered.

https://codesandbox.io/s/runtime-forest-b5nqmc?file=/src/App.js

Any help would be much appreciated

import React, {useState} from 'react';
import {Text, View, TouchableOpacity} from 'react-native';
import Swiper from 'react-native-deck-swiper';

const App = () => {
  const [count,setCount] = useState(0);

  return (
    <Swiper
      cards={['a', 'b', 'c']}
      renderCard={() => {
        return (
          <View>
            <TouchableOpacity onPress={() => {
              setCount(2);
              console.log("Clicked");

            }} style={{ backgroundColor: 'yellow', width:60 }}>
            <Text>Increase</Text>
            </TouchableOpacity>

            <Text>{count}</Text>
           
          </View>);
      }}/>
            
  );
};

export default App;
@iyansr
Copy link

iyansr commented Nov 7, 2022

same issue

@YoussefHenna
Copy link

You can assign a ref to the DeckSwiper and call ref.forceUpdate() accordingly to get around this.

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