See this is why I love writing. Yea, my code is just straight up wrong. I had my wires crossed and never had anyone tell me.I was carrying over a JSX thing. With JSX, if you want something like:
onClick={doThing(something)} // bad, don't do this
That would run the function immediately on render, not on a click. You have to do:
onClick={() => doThing(stuff)}
And I accidentally carried that over to .then chains with promises. Excellent catch, I will correct my code so that others don’t pick up this incorrect code. That being said, could you explain why we need to wrap a function in a function:
const showSaveAlertFor = (milliseconds) => () => {
setCurrentAlert(‘Saved!’);
...// vs no nesting
const showSaveAlertFor = (milliseconds) => {
setCurrentAlert(‘Saved!’);
...
I just ran the non-nested version and it worked as expected, but it’s possible there are performance or side effect implications that I’m not aware of.