---
search:
  exclude: true
changelog:
  category: Release
  version: 8.0.0
date: '2019-02-10T16:10:15Z'
seo:
  description: >-
    So now that Hooks have been out in the wild for a week, a few issues are
    starting to pop up. Especially relating to how refs are handled (#162). To
    fix this…
title: Rewritten Hooks and tests
type: changelog
---
So now that Hooks have been out in the wild for a week, a few issues are starting to pop up.
Especially relating to how refs are handled (#162). To fix this, the current API needs to be changed.

### New `useInView` API:

```js
const [ref, inView, entry] = useInView(options)
```

If you are already using the hook, then you will need to update your code, by changing:

```js
const Component = () => {
  const ref = useRef()
  const inView = useInView(ref, {
    threshold: 0,
  })

  return (
    <div ref={ref}>
      ...
    </div>
  )
}
``` 

Into:

```js
const Component = () => {
  const [ref, inView] = useInView({
    threshold: 0,
  })

  return (
    <div ref={ref}>
      ...
    </div>
  )
}
``` 


### Removed
* The `useIntersectionObserver` hook was removed in favor of the `useInView` hook.

## Tests

Tests have been rewritten using [react-testing-library](https://github.com/kentcdodds/react-testing-library). Before they were messing with the internals of the components to fake updates. It also just works with the new hooks.
