framework7io / framework7

Full featured HTML framework for building iOS & Android apps
http://framework7.io
MIT License
18.04k stars 3.23k forks source link

Cannot read properties of undefined (reading 'swipeToClose') #4135

Open 0x8000ff opened 1 year ago

0x8000ff commented 1 year ago

Describe the bug

A popup.params is not defined error popup when swipe down the popup. but there's no issue when the React strict mode is turned off

TypeError
Cannot read properties of undefined (reading 'swipeToClose')

HTMLDivElement.handleTouchStart
https://j4ygs3.csb.app/node_modules/framework7/components/popup/popup-class.js:112:62
HTMLDivElement.handleEvent
https://j4ygs3.csb.app/node_modules/dom7/dom7.esm.js:880:14
function handleTouchStart(e) {
  if (isTouched || !allowSwipeToClose || !popup.params.swipeToClose) return;

  if (popup.params.swipeHandler && $(e.target).closest(popup.params.swipeHandler).length === 0) {
    return;

To Reproduce

Steps to reproduce the behavior:

  1. Go to this link
  2. Click the swipe to close button.
  3. When the popup appears, swipe down.
  4. the error Cannot read properties of undefined (reading 'swipeToClose') will appear.
  5. Replace const STRICT = true; in line 11 of the codesandbox demo with const STRICT = false;, and repeat the step again, no error will appear

Expected behavior

When react is in strict mode, no errors are displayed.

Actual Behavior

When the strict mode is enabled, an undefined error appears.

Screenshots

https://i.imgur.com/O7k2cTM.png