Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@semantic-ui-react/event-stack
Advanced tools
Issues mentioned in `README` should be solved by other approaches: - `.addEventListener()` is blazing fast and is not a real performance issue - to solve issues with ordering in case when regular DOM event propogation is not available consider to use thi
Issues mentioned in README
should be solved by other approaches:
.addEventListener()
is blazing fast and is not a real performance issuePlease avoid usages of this library.
A React component for binding events on the global scope.
yarn add @semantic-ui-react/event-stack
# or
npm install @semantic-ui-react/event-stack
The EventStack
solves two design problems:
element.addListener()
.import React, { Component } from 'react'
import EventStack from '@semantic-ui-react/event-stack'
class MyComponent extends Component {
handleResize = () => {
console.log('resize')
}
render() {
return (
<div>
<EventStack name="resize" on={this.handleResize} target="window" />
</div>
)
}
}
When doing server side rendering, document and window aren't available. You can use a string as a target
, or check that they exist before rendering the component with exenv
, for example.
You should avoid passing inline functions for listeners, because this creates a new Function instance on every render, defeating EventListener
's shouldComponentUpdate
, and triggering an update cycle where it removes its old listeners and adds its new listeners (so that it can stay up-to-date with the props you passed in).
The EventStack
is a public API that allows subscribing a DOM node to events. The event subscription for
each unique DOM node creates a new EventTarget
object.
+------------+ +-------------+
| | 0..* | |
| EventStack | +------> | EventTarget |
| | | |
+------------+ +-------------+
Each EventTarget
is assigned to an unique DOM node. An EventTarget
tracks event handlers for
the target's DOM node. Making multiple subscriptions to a click
event for a single DOM node will
result in a single registered handler
for that DOM node. An EventPool
also handles EventPool
relations, it stores only unique pools.
+-------------+ +---------+
| | 0..* | |
| EventTarget | +------> | handler |
| | | |
+-------------+ +---------+
+ +-----------+
| 0..* | |
+----------------> | EventPool |
| |
+-----------+
A handler
is a generated function that will notify the corresponding subscribed EventPool
.
An EventPool
notifies its EventSet
, while an EventSet
stores a set of subscribed
event handlers. An EventSet
is also responsible for event ordering and dispatching to
subscribed handlers.
+-----------+ +----------+
| | 1 | |
| EventPool | +---> | EventSet |
| | | |
+-----------+ +----------+
The idea of a React component is taken from react-event-listener
.
FAQs
Issues mentioned in `README` should be solved by other approaches: - `.addEventListener()` is blazing fast and is not a real performance issue - to solve issues with ordering in case when regular DOM event propogation is not available consider to use thi
We found that @semantic-ui-react/event-stack demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.