An open API service indexing awesome lists of open source software.

https://github.com/patrickroberts/use-jquery-plugin

React hook for using jQuery plugins in components
https://github.com/patrickroberts/use-jquery-plugin

Last synced: 3 months ago
JSON representation

React hook for using jQuery plugins in components

Awesome Lists containing this project

README

        

# use-jquery-plugin
React hook for using jQuery plugins in components

## About

`use-jquery-plugin` simplifies hook-based usage of jQuery plugins in React.

The hook `useJQueryPlugin()` is the same as [`useLayoutEffect()`], but it returns a reference object to be passed to an HTML element. The effect passed to `useJQueryPlugin()` is provided with the jQuery selection containing the HTML element that the reference is assigned.

## Install

### [npm] (Recommended)

```sh
npm i use-jquery-plugin
```

### [unpkg]

```html

```

## Usage

```js
import React from 'react';
import useJQueryPlugin from 'use-jquery-plugin';

export default function App() {
const elemRef = useJQueryPlugin($elem => {
$elem.find('h1').css('font-family', 'Comic Sans');
}, []);

return (

Hello, world!



);
}
```

## API Documentation

Available on [Github Pages].

[`useLayoutEffect()`]: https://reactjs.org/docs/hooks-reference.html#uselayouteffect
[npm]: https://www.npmjs.com/package/use-jquery-plugin
[unpkg]: https://unpkg.com
[Github Pages]: https://patrickroberts.github.io/use-jquery-plugin/