Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[pull] master from gatsbyjs:master #533

Merged
merged 3 commits into from
Apr 26, 2021
Merged

[pull] master from gatsbyjs:master #533

merged 3 commits into from
Apr 26, 2021

Conversation

pull[bot]
Copy link

@pull pull bot commented Apr 26, 2021

See Commits and Changes for more details.


Created by pull[bot]

Can you help keep this open source service alive? 💖 Please sponsor : )

TylerBarnes and others added 3 commits April 26, 2021 10:02
…ents (#26861)

* add generic type to useScrollRestoration hook

this is required to match the type of `useRef` which requires the target
element type to be specified.

The hook can be used like the following:
```typescript
const MyComponent: React.FunctionComponent = () => {
  const scrollRestorationProps = useScrollRestoration<HTMLDivElement>(`some-key`)
  return (
    <div
      {...scrollRestorationProps}
      style={{ overflow: `auto` }}
    >
      Test
    </div>
  )
}
```

Fixes: #26458

* add tests for useScrollRestoration hook

* fix useScrollResotration to update position on location change

Previously, the scroll position was only updated when the using
component was re-rendered. This did not work when the hook is used in
a wrapping Layout component, becaus its persitent over location changes.
Adding the location key to useEffect will cause the scroll position is
updated every time the key changes.

* lint/ts fixes

Co-authored-by: Vladimir Razuvaev <vladimir.razuvaev@gmail.com>
@pull pull bot added the ⤵️ pull label Apr 26, 2021
@pull pull bot merged commit e64d9ff into attawayinc:master Apr 26, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants