Re: [csswg-drafts] [css-view-transitions-2] Allow synchronous snapshots (#9400)

Sorry for the delay, have been working further with View Transitions API.

There's not a place in the existing code where I would put the call. What I would do is have something like a `PageTransition` that accepts the latest path.

```jsx
<PageTransition path={latestUrl}>{content}</PageTransition>
```

This would be a React component that looks like

```javascript
class PageTransition extends React.Component {
  getSnapshotBeforeUpdate(prevProps) {
    if (this.props.path !== prevProps.path) {
      this.transition = document.snapshotViewTransition()
    }
  }
  
  componentDidUpdate() {
    if (this.transition) {
      this.transition.notifyUpdated()
    }
  }
}
```

-- 
GitHub Notification of comment by mattgperry
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9400#issuecomment-1805724812 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 10 November 2023 13:27:11 UTC