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

I can't erase the typed value, I don't have access to the value field which is common in inputText. #54

Open
marciojs186 opened this issue Jan 5, 2022 · 3 comments
Labels
question Further information is requested

Comments

@marciojs186
Copy link

How do I delete the input text value, I can't at all.

@marciojs186 marciojs186 added the question Further information is requested label Jan 5, 2022
@vxxvvxxv
Copy link

vxxvvxxv commented Feb 4, 2022

+1

@dleonven
Copy link

dleonven commented Feb 4, 2022

+1 Same here, I pass an initial value to the input and its not showing it. The "value" prop doesn't work.

@yarapolana
Copy link

yarapolana commented Mar 16, 2022

@marciojs186 @vxxvvxxv @dleonven
Hope this helps. Use the ref to clear the initial value.

  const [value, setValue] = useState('')
  const inputRef = createRef<TextInput>()
  
  useEffect(() => {
    // this is a fix for when masked input would force value 0 instead of placeholder
    if (value === '0') {
      inputRef.current?.clear()
    }
  }, [inputRef, value])

  return (
    ...
      <MaskedInput 
        ref={inputRef}
        type="currency" // it only works if type is currency
        placeholder={'initial value'}
        onChangeText={(text, rawText) => {
          setValue(rawText)
        }}
        value={value}
      />
    ...
  )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants