index.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import React from "react";
  2. import { StyleSheet, View, Text, Pressable } from "react-native";
  3. import useTestStore from "../../providers/test_store";
  4. import useSignUpStore from "../../providers/signup_form_store";
  5. export default function Index() {
  6. /**********************************狀態管理**********************************/
  7. const value = useTestStore((state) => state.value);
  8. const add = useTestStore((state) => state.add);
  9. const minus = useTestStore((state) => state.minus);
  10. /**********************************狀態管理**********************************/
  11. /**********************************組件初始化**********************************/
  12. /**********************************組件初始化**********************************/
  13. /**********************************異步函數**********************************/
  14. /**********************************異步函數**********************************/
  15. return (
  16. <View>
  17. <TestButton cb={minus} label="Minus" />
  18. <Text>States goes here: {value}</Text>
  19. <TestButton cb={add} label="Add" />
  20. </View>
  21. );
  22. }
  23. const TestButton = ({ label, cb }: { label: string; cb: () => void }) => (
  24. <Pressable
  25. onPress={() => {
  26. cb();
  27. }}
  28. >
  29. <Text
  30. style={{
  31. color: "#02677D",
  32. fontSize: 16,
  33. paddingVertical: 5,
  34. }}
  35. >
  36. {label}
  37. </Text>
  38. </Pressable>
  39. );
  40. const styles = StyleSheet.create({
  41. container: {
  42. flex: 1,
  43. },
  44. map: {
  45. width: "100%",
  46. height: "100%",
  47. },
  48. });