react-native-material-textfield icon indicating copy to clipboard operation
react-native-material-textfield copied to clipboard

Stuck with the first value property value from 0.13.0+

Open ahmedreda97 opened this issue 4 years ago • 6 comments

Starting from version 0.13.0 when i try to change the value property it doesn't reflect on the component. version 0.12.0 works well

ahmedreda97 avatar Jan 21 '20 11:01 ahmedreda97

@ahmedreda97 Thank you!

I have spent days trying to figure out why TextField would not update when my last released version of the app worked fine.

I rolled back react-native-material-textfield 0.12.0 and problem is fixed:

		"react": "^16.9.0",
		"react-native": "0.60.6",
		"react-native-material-textfield": "0.12.0",

This problem affects both iOS and Android.

esutton avatar Jan 28 '20 19:01 esutton

Same issue here. Version 0.12.0 works without problem, but starting from 0.13.0 TextField does not reflect passed value.

mchalimoniuk avatar Feb 07 '20 10:02 mchalimoniuk

Hey guys, i was going mad about this issue until blaming formik because of this. After replace this input for a different one i realized that formik had nothing to do with this. So reading closer this library documentation i found out this :

setValue()

Thus in my case i just need to do something like:

const CustomPicker = React.forwardRef(
  (props: Props, ref: React.Ref<OutlinedTextField>) => {
    const { label, textColor, name, theme } = props

    const [field, meta] = useField(name)
    React.useEffect(() => {
      ref.current.**setValue**(field.value)
    }, [field.value])
...

I hope this help to somebody

alexhoo avatar Mar 23 '20 14:03 alexhoo

The issue is still present in 0.16 (latest) version of this library ( checked on android device), please fix this.

EDIT: This is not an issue, this is just how the library works, you need to use setValue to set the value of TextField, the value prop only works as initialValue. This is explained in the issue #184

sriteja777 avatar Jul 08 '20 02:07 sriteja777

Hey guys, i was going mad about this issue until blaming formik because of this. After replace this input for a different one i realized that formik had nothing to do with this. So reading closer this library documentation i found out this :

setValue()

Thus in my case i just need to do something like:

const CustomPicker = React.forwardRef(
  (props: Props, ref: React.Ref<OutlinedTextField>) => {
    const { label, textColor, name, theme } = props

    const [field, meta] = useField(name)
    React.useEffect(() => {
      ref.current.**setValue**(field.value)
    }, [field.value])
...

I hope this help to somebody

Thanks for the pointer, it helped me in my case. I thought it was Formik issue as well until I came across this comment, and the comment by @sriteja777, anyone facing form reset issue with this library using formik should see this comment https://github.com/n4kz/react-native-material-textfield/issues/184

azhararmar avatar May 16 '21 19:05 azhararmar

The issue is still present in 0.16 (latest) version of this library ( checked on android device), please fix this.

EDIT: This is not an issue, this is just how the library works, you need to use setValue to set the value of TextField, the value prop only works as initialValue. This is explained in the issue #184

This is definitely a bug, or the properly should be called initialValue.

gentlee avatar Sep 25 '23 11:09 gentlee