Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrapping TextInput and using another ref causing error #289

Open
juliscotto opened this issue May 12, 2022 · 0 comments
Open

Wrapping TextInput and using another ref causing error #289

juliscotto opened this issue May 12, 2022 · 0 comments

Comments

@juliscotto
Copy link

I'm getting this error when I try to use the ref inside a wrapped TextInput:

TypeError: inputRef.current.clear is not a function. (In 'inputRef.current.clear()', 'inputRef.current.clear' is undefined)

My code:

const generateTestHook = useCavy(); const TestableTextInput = wrap(TextInput);

<TestableTextInput
        returnKeyType={"search"}
        returnKeyLabel={"search"}
        ref={generateTestHook("HomeScreen.SearchQuery", inputRef)}
        style={styles.input}
        maxLength={25}
        placeholder="¿Qué buscas?"
        placeholderTextColor={"#808080"}
        onChangeText={(text) => {
          setCurrentQuery(text);
          setOnSearch(true);
          setOnTextInput(true);
        }}
        onSubmitEditing={() => {
          if (currentQuery.replace(/\s/g, "").length) {
            setQuery(currentQuery);
          } else {
            setCurrentQuery("");
            setQuery("");
            setOnSearch(false);
          }
          setOnTextInput(false);
        }}
        value={currentQuery}
        onFocus={() => {
          setOnSearch(true);
          setOnTextInput(true);
          //sheetRef.current.snapTo(2);
        }}
        onBlur={() => {
          setOnTextInput(false);
        }}
 />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant