在iOS上,为了使我的文本可选,我使用了
<TextInput>
像这样的孩子:
const linkRef = useRef(null);
const handlePressIn = e => {
const pressedNodeHandle = e.nativeEvent.target;
const linkNodeHandle = findNodeHandle(linkRef.current);
const didPressLink = String(pressedNodeHandle) === String(linkNodeHandle);
console.log({ pressedNodeHandle, linkNodeHandle, didPressLink });
};
return (
<TextInput onPressIn={handlePressIn} multiline editable={false}>
[<Text style={styles.blue} ref={linkRef}>lorem</Text>, 'and ipsum and foo and bar and qux and baz']
</TextInput>
)
但是,即使按下
<Text>
我的
onPressIn
处理程序未检测到按下了正确的节点。有人知道怎么解决这个问题吗?