天道酬勤,学无止境

react-web

反应长按事件(react long press event)

问题 有没有办法在react-web 应用程序中添加长按事件? 我有地址列表。 长按任何地址时,我想触发事件以删除该地址,然后是确认框。 回答1 我创建了一个带有钩子的代码沙盒来处理长按和点击。 基本上,在鼠标按下、触摸开始事件时,会使用setTimeout创建一个计时器。 当提供的时间过去时,它会触发长按。 在鼠标抬起、鼠标离开、触摸结束等时,计时器被清除。 useLongPress.js import { useCallback, useRef, useState } from "react"; const useLongPress = ( onLongPress, onClick, { shouldPreventDefault = true, delay = 300 } = {} ) => { const [longPressTriggered, setLongPressTriggered] = useState(false); const timeout = useRef(); const target = useRef(); const start = useCallback( event => { if (shouldPreventDefault && event.target) { event.target.addEventListener("touchend"

2021-10-21 00:09:54    分类:技术分享    reactjs   create-react-app   dom-events   react-web

模块解析失败(Module parse failed)

问题 我将在网络上移植 GiftedMessanger。 我在 Webpack 包中遇到了一个错误: Krishti:react-native-web-exploding-hearts-master MacBook$ npm run web-bundle > react-native-web-exploding-hearts@0.0.1 web-bundle /Users/MacBook/WebWork/ReactWeb/react-native-web-exploding-hearts-master > NODE_ENV=production webpack --config web/webpack.config.js --colors Crawl: 6012ms Hash: d8df1262d7af54a6c6cd Version: webpack 1.12.10 Time: 10949ms [0] multi main 28 bytes {0} [built] + 339 hidden modules ERROR in ./~/react-native-gifted-messenger/GiftedMessenger.js Module parse failed: /Users/MacBook/WebWork/ReactWeb/react-native-web

2021-10-14 21:53:46    分类:技术分享    reactjs   react-native   webpack   babeljs   react-web

Module parse failed

I'm going to port GiftedMessanger on web. I'm stuck on an error in Webpack bundle: Krishti:react-native-web-exploding-hearts-master MacBook$ npm run web-bundle > react-native-web-exploding-hearts@0.0.1 web-bundle /Users/MacBook/WebWork/ReactWeb/react-native-web-exploding-hearts-master > NODE_ENV=production webpack --config web/webpack.config.js --colors Crawl: 6012ms Hash: d8df1262d7af54a6c6cd Version: webpack 1.12.10 Time: 10949ms [0] multi main 28 bytes {0} [built] + 339 hidden modules ERROR in ./~/react-native-gifted-messenger/GiftedMessenger.js Module parse failed: /Users/MacBook/WebWork

2021-10-12 12:05:50    分类:问答    reactjs   react-native   webpack   babeljs   react-web

react long press event

Is there a way to add long press event in react-web application? I have list of addresses. On long press on any address, I want to fire event to delete that address followed by a confirm box.

2021-04-12 11:28:35    分类:问答    reactjs   create-react-app   dom-events   react-web