danielgrijalva / overworld-old

:video_game: Discover, discuss and track your video games.
https://overworld.netlify.com/
120 stars 80 forks source link

TypeError when closing register modal without submitting #133

Closed mikesmith closed 5 years ago

mikesmith commented 5 years ago

Describe the bug TypeError occurs after closing Register modal without submitting.

To Reproduce Steps to reproduce the behavior:

  1. On Landing page, click on "Get Started"
  2. Observe the register modal appears with blank defaults
  3. Close the register modal by clicking on the 'x' (or outside the modal)

Expected behavior No TypeError when closing the register modal.

Desktop (please complete the following information):

Additional context

TypeError: Cannot read property 'length' of undefined
Register._this.handleClose [as onClose]
src/modules/app/components/register/index.js:52

  49 |     open: false
  50 |   });
  51 | 
> 52 |   if (this.props.errors.length > 0) {
     | ^  53 |     this.props.dismissErrors();
  54 |   }
  55 | };

From the console:

Uncaught TypeError: Cannot read property 'length' of undefined
    at Object.Register._this.handleClose [as onClose] (index.js:52)
    at apply (_apply.js:20)
    at baseInvoke (_baseInvoke.js:22)
    at apply (_apply.js:23)
    at _overRest.js:36
    at Modal.handleClose (Modal.js:72)
    at Object.onClick (Modal.js:95)
    at apply (_apply.js:20)
    at baseInvoke (_baseInvoke.js:22)
    at apply (_apply.js:23)
    at _overRest.js:36
    at Icon.js:48
    at HTMLUnknownElement.callCallback (react-dom.development.js:147)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:196)
    at invokeGuardedCallback (react-dom.development.js:250)
    at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:265)
    at executeDispatch (react-dom.development.js:571)
    at executeDispatchesInOrder (react-dom.development.js:596)
    at executeDispatchesAndRelease (react-dom.development.js:695)
    at executeDispatchesAndReleaseTopLevel (react-dom.development.js:704)
    at forEachAccumulated (react-dom.development.js:676)
    at runEventsInBatch (react-dom.development.js:844)
    at runExtractedEventsInBatch (react-dom.development.js:852)
    at handleTopLevel (react-dom.development.js:5030)
    at batchedUpdates$1 (react-dom.development.js:21469)
    at batchedUpdates (react-dom.development.js:2247)
    at dispatchEvent (react-dom.development.js:5110)
    at react-dom.development.js:21526
    at Object.unstable_runWithPriority (scheduler.development.js:255)
    at interactiveUpdates$1 (react-dom.development.js:21525)
    at interactiveUpdates (react-dom.development.js:2268)
    at dispatchInteractiveEvent (react-dom.development.js:5086)
danielgrijalva commented 5 years ago

Thanks for pointing it out. Will take a closer look at the code later today.

dreewp commented 5 years ago

I can work on this if no one else is.

There's a PR up right now from TonyDMorris, https://github.com/danielgrijalva/overworld/pull/141, that doesn't pass code coverage..but I think it's fine since the change is so small.