question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Imperative `isCrosswordCorrect()` function returns `false` after web page reloads

See original GitHub issue

Thanks for sharing this package!

I think I have run into a bug related to checking whether the crossword is correct.

When I fill in all the grid cells with correct letters and then call the imperative isCrosswordCorrect() function, the function returns true. That is what I expect it to do.

image

crosswordRef.current.isCrosswordCorrect(); // returns true ✅ 

However, when I then reload the web page (which leads to the grid being automatically re-populated with the same, correct letters) and then I call that same function again, the function returns false, whereas I expect it to return true since all the grid cells are still populated with correct letters.

image

crosswordRef.current.isCrosswordCorrect(); // returns false 😞 

At this point, if I call the imperative reset() function, fill in all the grid cells with the correct letters again, and then call the imperative isCrosswordCorrect() function again, the latter function once again returns true.

crosswordRef.current.reset();

image

image

crosswordRef.current.isCrosswordCorrect(); // returns true ✅ 

Here’s some information about the environment in which I observed this:

  • OS: Windows 10
  • Browser: Google Chrome Version 100.0.4896.88 (Official Build) (64-bit)
  • @jaredreisinger/react-crossword version: 4.3.2
  • React version: 17.0.2

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
JaredReisingercommented, Dec 13, 2022

… and sure enough, digging into the guess-loading code, I see a comment I left for myself:

      if (useStorage) {
        loadGuesses(newGridData, storageKey || defaultStorageKey);
        // TODO: find correct answers...
      }

So, yeah… I need to “find correct answers”! 🤦

1reaction
JaredReisingercommented, Dec 12, 2022

@gitname, thank you for the very-detailed repro case! I can look into this; my initial guess is that the “everything is correct” state is getting set during the “a letter has changed” processing, and isn’t getting set when loading the state from the browser’s local storage. 🤞🏼 it should be fairly easy to track down.

I think the non-page-reloading example is still causing the component to unmount and then remount, which would look exactly the same as a page reload as far as the component was aware. If that’s true, the same fix will take care of this scenario as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · JaredReisinger/react-crossword - GitHub
Imperative isCrosswordCorrect() function returns false after web page reloads. #271 opened on Apr 12 by gitname · 3. a11y issues preventing usage by...
Read more >
Page reloads even after return false in ajax $.post request
As you upload an image (my mistake, forgot that first!) : Important parts are the ones needed for upload otherwise it will fail...
Read more >
location.reload() - Web APIs | MDN
The location.reload() method reloads the current URL, like the Refresh button.
Read more >
data.refresh (Client API reference) - Power Apps
In this article. Syntax; Parameter. Asynchronously refreshes and optionally saves all the data of the form without reloading the page.
Read more >
force:refreshView - Salesforce Lightning Component Library
This example refreshes the view after an action is successfully completed. If you fire this event on a Lightning page, such as a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found