I have the following code and I am getting error of "count" is read-only:
import React, {useState} from 'react';
import {View, Text, StyleSheet, Button} from 'react-native';
const CounterScreen = () => {
const [count, setCount] = useState(0);
return (
<View>
<Button onPress={() => setCount(count++)} title="Increase" />
<Button onPress={() => setCount(count--)} title="Decrease" />
<Text>Current Counter: {count}</Text>
</View>
);
};
const styles = StyleSheet.create({});
export default CounterScreen;
But if I use setCount(count + 1) instead of setCount(count++), it works perfectly. What is the difference here between count + 1 and count++