Skip to content
Discussion options

You must be logged in to vote

hi.
This is simple solution for your question.

import {View, Text, StyleSheet, TouchableOpacity} from 'react-native';
import React from 'react';
import Animated, {
  useAnimatedStyle,
  useSharedValue,
  withDelay,
  withTiming,
} from 'react-native-reanimated';

export function Onclick() {
  const toggle = useSharedValue(0);
  const activeStyle = useAnimatedStyle(() => {
    return {
      backgroundColor: withDelay(
        500,
        withTiming(toggle.value === 1 ? 'yellow' : 'transparent'),
      ),
    };
  });
  return (
    <View style={styles.container}>
      <TouchableOpacity
        activeOpacity={1}
        onPress={() => {
          toggle.value = 1;
          setTimeout(()…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@MatteoBuffo
Comment options

Answer selected by MatteoBuffo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants