-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
Description
Issue
I wanna use TextInput ref to set user selection, The react native has setSelection method, But it's not work on react-native-paper.
I saw the source code it dosent export this method. (
| React.useImperativeHandle(ref, () => ({ |
Example
import { View, TextInput } from 'react-native';
const ReceiveScreen: ScreenPage<{ initialAmount?: number }> = ({ route: { params } }) => {
const f = useRef<TextInput>(null);
return (
<Screen>
<TextInput value={'Hi this is a input'} ref={f} />
<Button
onPress={() => {
f.current?.focus();
// The TextInput from 'react-native' is work fine, but it's undefined while from 'react-native-paper'
f.current?.setSelection(0, 3);
}}
>
Select
</Button>
</Screen>
);
};💡 I have tried to use setNativeProps instead, but it's not work both on react-native and react-native-paper.
Currently, I am doing it by rewriting the render, I think it's better to export this usefull method.