Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nekr/preact-delegate
Preact delegate DOM events
https://github.com/nekr/preact-delegate
delegate dom events preact
Last synced: 11 days ago
JSON representation
Preact delegate DOM events
- Host: GitHub
- URL: https://github.com/nekr/preact-delegate
- Owner: NekR
- License: mit
- Created: 2017-03-02T23:11:58.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-03T01:42:41.000Z (almost 8 years ago)
- Last Synced: 2025-01-10T04:25:00.847Z (14 days ago)
- Topics: delegate, dom, events, preact
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 19
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# preact-delegate
Delegate DOM events with Preact (since Preact doesn't do that by default).
## Install
```sh
npm install preact-delegate --save-dev
```## Usage
Just wrap your root element from where to capture events with `DelegateContainer` and then wrap individual elements which should receive events with `DelegateElement`. See example:
```js
import { Component } from 'preact';
import { DelegateContainer, DelegateElement } from 'preact-delegate';class MyComponent extends Component {
constructor(...args) {
super(...args);this.onClick = (e) => {
console.log(e.target);
};
}render({ items }) {
return
{items.map(item => (
{ item.text }
))}
}
}
```## LICENSE
[MIT](LICEMSE.md)