1.1.11 • Published 2 years ago

@notthatnathan/use-element-size v1.1.11

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

useElementSize

React hook to track the size of an element. Pass an element ref that you’d like to observe. Its initial and changing width and height are returned.

Example

const ParentComponent = () => {
  const parentRef = useRef(null)
  const [width, height] = useElementSize(parentRef, [300, 100])

  return (
    <div ref={parentRef}>
      <MyComponent parentWidth={width} parentHeight={height} />
    </div>
  )
}

Arguments

  • ref: The element ref to watch for size changes.
  • defaultSize (optional): Provide a default size to return if a measurement isn’t yet available. Helpful for server-side rendering.

Read the blog post

1.1.11

2 years ago

1.1.10

2 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago