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.

Using event.preventDownshiftDefault = true triggers React warning

See original GitHub issue
  • downshift version: 1.31.2
  • node version: 8.9.4
  • npm (or yarn) version: npm 5.8.0

Relevant code or config

{...getItemProps({
  onClick: event => {
    event.preventDownshiftDefault = true;
  },
  item,
  label: item,
})}

What you did: I was preventing the default downshift handler from executing.

What happened: React triggered a warning

index.js:2178 Warning: This synthetic event is reused for performance reasons. If you’re seeing this, you’re adding a new property in the synthetic event object. The property is never released. See https://fb.me/react-event-pooling for more information. Reproduction repository:

Problem description: Functionality works as expected, but not sure if the warning can be prevented. Suggested solution: If warning is normal for Dev mode, add a note to docs.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
cudbacommented, Apr 24, 2018

Just stumbled upon this aswell. An other issue that appears is that on subsequent events (like keydown), the event.preventDownshiftDefault = true is still set (as the react warning suggests). So for example keydown navigation doesnt work anymore. For now, i’m setting it to false in the else clause:

getInputProps({
     onKeyDown(event) {
         if (event.key === 'Enter') {
            event.preventDownshiftDefault = true;
         } else {
            event.preventDownshiftDefault = false;
         }
     }
})
1reaction
jonavilacommented, Apr 2, 2018

@kentcdodds I thought to myself: “The feature has been out for almost a month. I’m must doing something wrong, hahaha”. BTW, Downshift is awesome. I’ve just been getting familiar with it in the past day or so. I’ll dig up ticket on why event.preventDefault is not a good option.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React & event.preventDefault() - Medium
When React starts up, it starts listening for all events at the top level using a single event listener. So, this is great...
Read more >
downshift/README.md - UNPKG
55, Downshift has proven to be a versatile React component which can be used not ... you can set the event's `preventDownshiftDefault` property...
Read more >
Combobox Primitive - Paste: The Design System for building ...
Use an input element and set the role of Combobox in the getToggleButtonProps getter ... you can set the event's preventDownshiftDefault property to...
Read more >
Is there a way to prevent an event to be triggered based on a ...
onClick="..." : null>Test</div> . Of course, this doesn't work. Is this possible? P.S. Remember, I am using React, this code is just an...
Read more >
Downshift: The Answer to Building Accessible and Visually ...
In the realm of React UI Component Frameworks, there are lots of ... The use of render prop is at the core of...
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