JaredReisinger / react-crossword

A flexible, responsive, and easy-to-use crossword component for React apps.
https://react-crossword.jaredreisinger.com
MIT License
168 stars 80 forks source link

prevent overwriting stored guesses in StrictMode #527

Closed wtobi closed 12 months ago

wtobi commented 1 year ago

Check for empty gridData to prevent overwriting stored guesses in React.StrictMode

wtobi commented 1 year ago

When the app is mounted in strict mode (https://beta.reactjs.org/reference/react/StrictMode), loading stored guesses doesn't work. At least not with development builds.

This is a quick and easy fix for that.

A better way to fix that might be to restructure the useEffects somehow. But I'm no React expert, so don't know how or if that'd really help.

Anyway, what happens is that saveGuesses is called with an empty gridData array because of StrictMode's double rendering (I think).

Sorry for not following your commit message guidelines. I couldn't check out the project on this machine and had to use GitHub's online editor.