You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`initialValue` is deprecated, use `value` instead
244
+
-`value` can be used to specify and override the value of the input field
245
+
- For example, `value="hello world"` will print `hello world` into the input field
246
+
- Default is undefined
247
+
- ❗ If you want to clean the input field based on side effects use `value` of empty string.
248
+
- ❗ Use `value` only if you want complete control over the value of the input field. `react-datalist-input` will priotize whatever value is set over anything the user selects or has selected. If you use `value`, you will have to update it on your own using the `onClick`, `onInput`, and`onSelect` lifecycle methods.
249
+
- ❗ Don't confuse this with a placeholder (see placerholder prop). This property sets the actual value of the input field.
250
+
- ❗ The flags `clearInputOnSelect` and `clearInputOnClick` won't work and have to be implemented via the mentioned lifecycle methods.
211
251
212
-
- Specify an initial value for the input field.
213
-
- For example, `initialValue={'hello world'}` will print `hello world` into the input field on first render.
214
-
- Default is empty string.
215
-
- Caution: Don't confuse this with a placeholder (see placerholder prop), this is an actual value in the input
216
-
and supports uses cases like saving user state or suggesting a search value.
252
+
The following `useEffect` is used to decide if the component should update with the new `value` property:
253
+
254
+
```javascript
255
+
useEffect(() => {
256
+
// the parent component can pass its own value prop that will override the internally used currentInput
257
+
// this will happen only after we are have finished the current computing step and the dropdown is invisible
258
+
// (to avoid confusion of changing input values for the user)
259
+
/*
260
+
* we have to distinguish undefined and empty string value
261
+
* value == undefined => not set, use internal current input
262
+
* value !== undefined => value set, use value and override currentInput
263
+
* this enables value === '' to clear the input field
Copy file name to clipboardExpand all lines: package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
{
2
2
"name": "react-datalist-input",
3
-
"version": "2.0.0",
3
+
"version": "2.1.0",
4
4
"description": "This package provides a react component as follows: an input field with a drop down menu to pick a possible option based on the current input.",
0 commit comments