提问人:OVER-C 提问时间:9/26/2023 更新时间:9/26/2023 访问量:15
ReactNative 如何将对 TextInput 的关注处理到自定义组件中
ReactNative how to handle a focus on TextInput into a custom component
问:
我有两个问题/问题要解决。
我需要创建一个 TextInput 自定义组件来管理 CSS、行为和图标。
一些代码,我保持简单:
// imports
export function CustomTextInput ({
autoCorrect,
autoFocus,
caretHidden,
contextMenuHidden,
defaultValue,
editable,
enterKeyHint,
inputMode,
onFocus
// ... Much longer list
}) {
// Some code
return (
<View>
<TextInput
autoCorrect={autoCorrect}
autoFocus={autoFocus}
caretHidden={caretHidden}
contextMenuHidden={contextMenuHidden}
defaultValue={defaultValue}
editable={editable}
enterKeyHint={enterKeyHint}
inputMode={inputMode}
cursorColor={primaryColor}
onFocus={onFocus}
// ... Much longer list
/>
</View>
)
}
第一个问题:我们是否有解决方案可以将所有“原始”道具从 TextInput 获取到这个组件中,而无需像我一样一一传递所有内容?
第二个问题:我想改变用户何时成为焦点。但是我需要保持传递自定义方法。backgroundColor
onFocus
我希望我在这些问题上是清楚的。
谢谢。
对于这种方法,我尝试了昏迷。onFocus
array
答: 暂无答案
评论