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

https://github.com/tobua/react-sprite

React SVG Sprite Component with Polyfill for older browsers.
https://github.com/tobua/react-sprite

Last synced: 3 months ago
JSON representation

React SVG Sprite Component with Polyfill for older browsers.

Awesome Lists containing this project

README

        

# ReactSprite

> Dynamic SVG Sprite Polyfill Component for React

```jsx

// Will be turned into

```

Not a whole lot 😛 but more importantly for browsers that do not support the use tag for SVG sprites the plugin will request and cache the sprite, query it for the relevant symbol and insert it manually into the DOM.

## Installation & Usage

```
npm i react-sprite
```

```jsx
import { useState } from 'react'
import { createRoot } from 'react-dom/client'
import ReactSprite from 'react-sprite'

const SimpleIcon = () =>

const StatefulIcon = () => {
const [icon, toggleOpen] = useState('closed')

return (
toggleOpen(icon === 'closed' ? 'open' : 'closed')}
/>
)
}

const WithOptions = (props) => (
alert('Hello there!')}
{...props}
/>
)

createRoot(document.body).render(
<>



>
)
```