0

So as the heading says, i want to add custom props to the in-built textInput component in react-native (expo).

So what i tried is i got to the location node_modules\react-native\ReactAndroid\src\main\java\com\facebook\react\views\textinput\ReactTextInputManager.java where other props are defined (correct me if i am wrong).

There i added this code;

// created a prop to hide suggestions when password is visible


@ReactProp(name = "hideSuggestions", defaultBoolean = false)
  public void setHideSuggestions(ReactEditText view, boolean hideSuggestions) {
    updateStagedInputTypeFlag(
        view,
        hideSuggestions ? InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD : 0);
  }

Then in C:\Users\irfan\AppData\Local\Microsoft\TypeScript\4.5\node_modules\@types\react-native\index.d.ts;

    hideSuggestions?: boolean | undefined;

And in the textInput, i added hideSuggestions={true}.

But it is not working (it also doesn't give any error).

So how can i do that.

Also i want to metion here that the above code is just a guess from me how it should work.

I actually copied the code from the other prop and just edited that.

Irfan wani
  • 4,084
  • 2
  • 19
  • 34
  • 1
    It's not a good idea to edit a file in node_modules, what I suggest to you is to create a component in your project and add the props you want to TextInput and then you could simply use your custom text input instead of react native built text input – Mahdi N Jan 07 '22 at 09:11
  • 1
    Second on the custom component. React Native is built with the assumption that you'll build your own component wrappers to do special things in your application. – Austin Poulson Jan 07 '22 at 10:13

0 Answers0