diff --git a/README.md b/README.md index d4028ddb..672aa23b 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,33 @@ import { Resizable } from 're-resizable'; ``` +### Example with `localStorage` + +```javascript +import { useState, useEffect } from "react"; +import { Resizable } from 're-resizable'; + +export default function MyComponent() { + const [width, setWidth] = useState(localStorage.getItem("componentWidth") || 250); + + useEffect(() => { + localStorage.setItem("componentWidth", width); + }, [width]); + + return ( + { + setWidth(ref.offsetWidth); + }} + }} + > + Sample with size + + ); +} +``` + ## Props #### `defaultSize?: { width: (number | string), height: (number | string) };`