I’m trying to dynamically change Spectrum theme based on kuiBrightness changes by passing the value (after mapping it to the appropriate Spectrum value) into a Redux store. Everything works as expected until Photoshop crashes as soon as a new kuiBrightness value is clicked on in the PS preferences dialog. After debugging I can trace it to when Redux tries to update the store. When I console.log the payload value it’s as expected.
Elsewhere in my code I have a menu to select Spectrum theme and passing the string value from there successfully updates the store.
I get a crash report but I’ll save posting it until someone asks as it’s long.
I use the second option all over my plugin. Don’t recall for sure now, but I think I saw some recommendation somewhere to keep related actions and thunks inside the state, which they are interacting with.
But honestly I don’t see anything wrong with your code too
How do you get setTheme() action in App.jsx?
Thanks, I’ll try scoping the action later.
The weird thing is that also I call the same setTheme action outside of the <Storeprovider> like this and it works.
After some further testing I can see that what was actually causing the crash was the Menu component I have for selecting the Spectrum theme elsewhere in my code:
props.selected is spectrum.theme from the store. I guess what’s happening is that changing selected triggers the parent Menu onchange event and bam, stack overflow.
I’ve removed the selected ternary and am moving on with my life, I can live without the tick indicator as I display the selected value in the PickerButton.
So is it because of infinite loop? Also I thought that false === true in spectrum attributes so you have to assign undefined instead of false to make it work.