'React Native Typescript : how to resolve an error of type of parameter for a variable

I'm doing a project in react native (typescript) and here is my issue : I have this error Argument of type 'GestureResponderEvent' is not assignable to parameter of type 'SetStateAction<string>'.ts(2345) with this part of my code, at the i of setSelected :

<View style={{}}>
          <Text style={styles.texteti}>Heading, paragraphe, lien</Text>
          {state.map((i) => (
            <TouchableOpacity onPress={(i) => setSelected(i)}> 
              <Text>{i} Here</Text>
            </TouchableOpacity>
          ))}
          {selected == "v1Visible" && (
            <View>
              <Text>View 1</Text>
            </View>
          )}
          {selected == "v2Visible" && (
            <View>
              <Text>View 2</Text>
            </View>
          )}
          {selected == "v3Visible" && (
            <View>
              <Text>View 3</Text>
            </View>
          )}
          {selected == "v4Visible" && (
            <View>
              <Text>View 4</Text>
            </View>
          )}
        </View>

Anyone has an idea of how to resolve this



Solution 1:[1]

Thank you guys for the comments, I found the problem, I noticed a sentence through the log: "QQmlEngine: Illegal attempt to connect to settingWorkCenter(0x7f7c000fe0) that is in a different thread than the QML engine QQmlApplicationEngine(0x7ff2267c38)." I instantiate the singleton object of settingWorkCenter in another thread, and then register the singleton object to the qml global context through setContextProperty in the main thread. So this error is generated I'm playing stackflower for the first time and don't know how to upload the code

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 qtFans