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

set default to none. #5

Open
bhuvana-abhisheg opened this issue Jun 26, 2019 · 3 comments
Open

set default to none. #5

bhuvana-abhisheg opened this issue Jun 26, 2019 · 3 comments

Comments

@bhuvana-abhisheg
Copy link

Hi.. I am using your component in our app. The smilies look great. Thanks for such an awesome component. We need to customise the component as per our requirement. By default the center smiley is selected. Can we change the default selection to none ? Pls let me know.

@bneigher
Copy link

bneigher commented Dec 25, 2019

@bhuvana-abhisheg just render based on state the component without any of the animated props

return (
      <View style={styles.reactions}>
        {REACTIONS.map((reaction, idx) => {
          const u = idx * DISTANCE;

          return (
            <TouchableOpacity
              onPress={() => {
                this.setState({ interacted: true });
                this.updatePan(u);
              }}
              activeOpacity={0.9}
              key={idx}>
              <View style={styles.smileyWrap}>
                <Animated.Image source={reaction.src} style={[styles.smiley]} />
              </View>

              <Animated.Text style={[styles.reactionText]}>
                {reaction.label}
              </Animated.Text>
            </TouchableOpacity>
          );
        })}
      </View>
    );

only when this.state.interacted is true, render the original return of the component

@aravi365
Copy link

aravi365 commented Jul 6, 2020

Hi.. I am using your component in our app. The smilies look great. Thanks for such an awesome component. We need to customise the component as per our requirement. By default the center smiley is selected. Can we change the default selection to none ? Pls let me know.

did you able to solve this? If yes, can you please share the code.

@aravi365
Copy link

@bhuvana-abhisheg just render based on state the component without any of the animated props

return (
      <View style={styles.reactions}>
        {REACTIONS.map((reaction, idx) => {
          const u = idx * DISTANCE;

          return (
            <TouchableOpacity
              onPress={() => {
                this.setState({ interacted: true });
                this.updatePan(u);
              }}
              activeOpacity={0.9}
              key={idx}>
              <View style={styles.smileyWrap}>
                <Animated.Image source={reaction.src} style={[styles.smiley]} />
              </View>

              <Animated.Text style={[styles.reactionText]}>
                {reaction.label}
              </Animated.Text>
            </TouchableOpacity>
          );
        })}
      </View>
    );

only when this.state.interacted is true, render the original return of the component

can you elaborate the full code?

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