import React from "react";
import { useSelector, useDispatch } from "react-redux";
import { counterSlice, decrement, increment } from "../reducers/counterReducer";
import { Button, Text, View } from "react-native";
import store from "../store";

export default function Counter() {
  /**********************************狀態管理**********************************/
  const value = useSelector((state: any) => state.counter.value);
  const dispatch = useDispatch();
  /**********************************狀態管理**********************************/
  /**********************************組件初始化**********************************/
  /**********************************組件初始化**********************************/
  /**********************************異步函數**********************************/
  /**********************************異步函數**********************************/
  return (
    <View>
      <View style={{ flexDirection: "row", alignItems: "center" }}>
        <Button title="Increment" onPress={() => dispatch(increment())} />
        <Text>{value}</Text>
        <Button title="Decrement" onPress={() => dispatch(decrement())} />
      </View>
    </View>
  );
}
