use-with-viewbox
v1.0.0
Published
[![Build Status](https://travis-ci.org/the-road-to-learn-react/use-with-viewbox.svg?branch=master)](https://travis-ci.org/the-road-to-learn-react/use-with-viewbox) [![Slack](https://slack-the-road-to-learn-react.wieruch.com/badge.svg)](https://slack-the-r
Downloads
2
Readme
useWithViewbox React Hook
Custom hook to add a viewbox attribute to your SVG in case it's missing. It calculates the viewbox based on the rendered svg element with its height and width. Read more about it here.
Installation
npm install use-with-viewbox
Usage
import useWithViewbox from 'use-with-viewbox';
const MySvg = (props) => {
const ref = React.createRef();
useViewbox(ref);
return (
<svg ref={ref} {...props}>
// SVG Content ...
</svg>
);
};
export default MySvg;
Contribute
git clone [email protected]:the-road-to-learn-react/use-with-viewbox.git
cd use-with-viewbox
npm install