Coloris and react state? #183
Replies: 2 comments 1 reply
-
|
Hello, I don't have experience running Coloris in React, but I can try and help diagnose the problem if you provide a link where I can test. |
Beta Was this translation helpful? Give feedback.
-
|
Well, I was ultimately able to get it working! I have an outstanding question on Stack Overflow. React does make it challenging to work with libraries not designed for React, sometimes. I'm quite new to React. There seemed to be some interaction between a closure scope, React state, and Coloris. I don't understand why my fix works but it does. I am curious if it's okay to repeatedly do My code is at https://github.com/codergal6502/ChocoWindow/blob/main/studio/src/components/modal-components/TileSetColorPalette.jsx. Though the call to In case you're curious, the fix I mentioned was to add a piece of React state between this function // without these two, colorSubstitutions in handleColorSubstitution is always one render behind.
const [colorisFixColorSubstitute, setColorisFixColorSubstitute] = useState();
useEffect(() => { if (colorisFixColorSubstitute) handleColorSubstitution(colorisFixColorSubstitute); }, [colorisFixColorSubstitute]); |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi hi. I'm trying to use Coloris in a React application. Have others had success with that combination? My initial implementation that doesn't use Coloris works fine, but I'm finding there are issues with my React state being stale in ways I can't explain by JavaScript closure issues, though I'm far from an expert. Can I post some code here? I really hope I can get Coloris working. It's pretty great!
Beta Was this translation helpful? Give feedback.
All reactions