From fdf79c193643b5d7a17465974fae0bc6255c5097 Mon Sep 17 00:00:00 2001 From: iChengbo Date: Tue, 17 Aug 2021 11:37:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20offXXXXChange=20?= =?UTF-8?q?=E4=B8=8D=E7=94=9F=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/apis/pages/device/accelerometer/index.tsx | 12 ++++++------ src/pages/apis/pages/device/deviceMotion/index.tsx | 12 ++++++------ src/pages/apis/pages/device/gyroscope/index.tsx | 12 ++++++------ src/pages/apis/pages/device/network/index.tsx | 12 ++++++------ src/pages/apis/pages/location/index/index.tsx | 12 ++++++------ src/pages/apis/pages/surface/keyboard/index.tsx | 12 ++++++------ 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/pages/apis/pages/device/accelerometer/index.tsx b/src/pages/apis/pages/device/accelerometer/index.tsx index 9e495cb01999..b91ea177cb88 100644 --- a/src/pages/apis/pages/device/accelerometer/index.tsx +++ b/src/pages/apis/pages/device/accelerometer/index.tsx @@ -2,12 +2,12 @@ * @Author: iChengbo * @Date: 2021-08-02 15:44:28 * @LastEditors: iChengbo - * @LastEditTime: 2021-08-03 11:04:30 + * @LastEditTime: 2021-08-17 11:31:34 * @FilePath: /taro-react-native/src/pages/apis/pages/device/accelerometer/index.tsx */ import Taro from "@tarojs/taro-rn"; import { Button, View } from "@tarojs/components"; -import { useState } from "react"; +import { useCallback, useState } from "react"; import JSONTree from '../../../../components/jsontree'; import "./index.scss"; @@ -16,15 +16,15 @@ const Index = () => { const [accelerometer1, setAccelerometer1] = useState({}); const [accelerometer2, setAccelerometer2] = useState({}); - const _handleCallback1 = (res) => { + const _handleCallback1 = useCallback((res) => { console.log("回调函数 C1", res); setAccelerometer1(res); - } + }, []); - const _handleCallback2 = (res) => { + const _handleCallback2 = useCallback((res) => { console.log("回调函数 C2", res); setAccelerometer2(res); - } + }, []); return ( diff --git a/src/pages/apis/pages/device/deviceMotion/index.tsx b/src/pages/apis/pages/device/deviceMotion/index.tsx index 46e7ecfbea87..9bacd0402171 100644 --- a/src/pages/apis/pages/device/deviceMotion/index.tsx +++ b/src/pages/apis/pages/device/deviceMotion/index.tsx @@ -2,12 +2,12 @@ * @Author: iChengbo * @Date: 2021-08-02 15:44:28 * @LastEditors: iChengbo - * @LastEditTime: 2021-08-03 11:20:13 + * @LastEditTime: 2021-08-17 11:33:26 * @FilePath: /taro-react-native/src/pages/apis/pages/device/deviceMotion/index.tsx */ import Taro from "@tarojs/taro-rn"; import { Button, View } from "@tarojs/components"; -import { useState } from "react"; +import { useCallback, useState } from "react"; import JSONTree from '../../../../components/jsontree'; import "./index.scss"; @@ -16,15 +16,15 @@ const Index = () => { const [deviceMotion1, setDeviceMotion1] = useState({}); const [deviceMotion2, setDeviceMotion2] = useState({}); - const _handleCallback1 = (res) => { + const _handleCallback1 = useCallback((res) => { console.log("回调函数 C1", res); setDeviceMotion1(res); - } + }, []); - const _handleCallback2 = (res) => { + const _handleCallback2 = useCallback((res) => { console.log("回调函数 C2", res); setDeviceMotion2(res); - } + }, []); return ( diff --git a/src/pages/apis/pages/device/gyroscope/index.tsx b/src/pages/apis/pages/device/gyroscope/index.tsx index cac64407d43a..e77014f9dd44 100644 --- a/src/pages/apis/pages/device/gyroscope/index.tsx +++ b/src/pages/apis/pages/device/gyroscope/index.tsx @@ -2,12 +2,12 @@ * @Author: iChengbo * @Date: 2021-08-02 15:44:28 * @LastEditors: iChengbo - * @LastEditTime: 2021-08-03 11:05:48 + * @LastEditTime: 2021-08-17 11:33:57 * @FilePath: /taro-react-native/src/pages/apis/pages/device/gyroscope/index.tsx */ import Taro from "@tarojs/taro-rn"; import { Button, View } from "@tarojs/components"; -import { useState } from "react"; +import { useCallback, useState } from "react"; import JSONTree from '../../../../components/jsontree'; import "./index.scss"; @@ -16,15 +16,15 @@ const Index = () => { const [gyroscope1, setGyroscope1] = useState({}); const [gyroscope2, setGyroscope2] = useState({}); - const _handleCallback1 = (res) => { + const _handleCallback1 = useCallback((res) => { console.log("回调函数 C1", res); setGyroscope1(res); - } + }, []); - const _handleCallback2 = (res) => { + const _handleCallback2 = useCallback((res) => { console.log("回调函数 C2", res); setGyroscope2(res); - } + }, []); return ( diff --git a/src/pages/apis/pages/device/network/index.tsx b/src/pages/apis/pages/device/network/index.tsx index f007e0717ca6..1b34cb7cfccf 100644 --- a/src/pages/apis/pages/device/network/index.tsx +++ b/src/pages/apis/pages/device/network/index.tsx @@ -2,12 +2,12 @@ * @Author: iChengbo * @Date: 2021-08-02 15:44:28 * @LastEditors: iChengbo - * @LastEditTime: 2021-08-03 15:40:10 + * @LastEditTime: 2021-08-17 11:34:23 * @FilePath: /taro-react-native/src/pages/apis/pages/device/network/index.tsx */ import Taro from "@tarojs/taro-rn"; import { Button, View } from "@tarojs/components"; -import { useState } from "react"; +import { useCallback, useState } from "react"; import JSONTree from '../../../../components/jsontree'; import "./index.scss"; @@ -16,15 +16,15 @@ const Index = () => { const [networkStatus1, setNetworkStatus1] = useState({}); const [networkStatus2, setNetworkStatus2] = useState({}); - const _handleCallback1 = (res) => { + const _handleCallback1 = useCallback((res) => { console.log("回调函数 C1", res); setNetworkStatus1(res); - } + }, []); - const _handleCallback2 = (res) => { + const _handleCallback2 = useCallback((res) => { console.log("回调函数 C2", res); setNetworkStatus2(res) - } + }, []); return ( diff --git a/src/pages/apis/pages/location/index/index.tsx b/src/pages/apis/pages/location/index/index.tsx index c1d28a3dc424..02b7f68cc6e7 100644 --- a/src/pages/apis/pages/location/index/index.tsx +++ b/src/pages/apis/pages/location/index/index.tsx @@ -2,11 +2,11 @@ * @Author: iChengbo * @Date: 2021-08-03 18:55:14 * @LastEditors: iChengbo - * @LastEditTime: 2021-08-04 17:14:29 + * @LastEditTime: 2021-08-17 11:35:32 * @FilePath: /taro-react-native/src/pages/apis/pages/location/index/index.tsx */ import Taro from '@tarojs/taro'; -import { useState } from "react"; +import { useCallback, useState } from "react"; import { View, Button } from '@tarojs/components'; import JSONTree from '../../../../components/jsontree'; @@ -17,15 +17,15 @@ const PageView = () => { const [location1, setLocation1] = useState({}); const [location2, setLocation2] = useState({}); - const _handleCallback1 = (res) => { + const _handleCallback1 = useCallback((res) => { console.log("回调函数 C1", res); setLocation1(res) - } + }, []); - const _handleCallback2 = (res) => { + const _handleCallback2 = useCallback((res) => { console.log("回调函数 C2", res); setLocation2(res) - } + }, []); return ( diff --git a/src/pages/apis/pages/surface/keyboard/index.tsx b/src/pages/apis/pages/surface/keyboard/index.tsx index 5fa1836b237a..3a8517c3f713 100644 --- a/src/pages/apis/pages/surface/keyboard/index.tsx +++ b/src/pages/apis/pages/surface/keyboard/index.tsx @@ -2,10 +2,10 @@ * @Author: iChengbo * @Date: 2021-08-03 17:17:28 * @LastEditors: iChengbo - * @LastEditTime: 2021-08-03 17:59:01 + * @LastEditTime: 2021-08-17 11:35:58 * @FilePath: /taro-react-native/src/pages/apis/pages/surface/keyboard/index.tsx */ -import { useState } from 'react'; +import { useCallback, useState } from 'react'; import Taro from '@tarojs/taro'; import { View, Button, Text, Input } from '@tarojs/components'; @@ -14,13 +14,13 @@ import './index.scss' const PageView = () => { const [value, setValue] = useState(''); - const _handleCallback1 = (res) => { + const _handleCallback1 = useCallback((res) => { console.log("回调函数 C1", res); - } + }, []); - const _handleCallback2 = (res) => { + const _handleCallback2 = useCallback((res) => { console.log("回调函数 C2", res); - } + }, []); return (