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
// Update the ref so that the next setState callback has the most recent value.
51
+
valueRef.current=newValue;
52
+
53
+
// Always trigger a setState, even when controlled, so that the layout effect above runs to reset the value.
54
+
setStateValue(newValue);
47
55
48
-
if(typeofvalue==='function'){
49
-
if(process.env.NODE_ENV!=='production'){
50
-
console.warn('We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320');
51
-
}
52
-
// this supports functional updates https://reactjs.org/docs/hooks-reference.html#functional-updates
53
-
// when someone using useControlledState calls setControlledState(myFunc)
54
-
// this will call our useState setState with a function as well which invokes myFunc and calls onChange with the value from myFunc
55
-
// if we're in an uncontrolled state, then we also return the value of myFunc which to setState looks as though it was just called with myFunc from the beginning
56
-
// otherwise we just return the controlled value, which won't cause a rerender because React knows to bail out when the value is the same
0 commit comments