Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[v6] Disable React.useTransition before cutting stable #7308

Closed
gaearon opened this issue May 4, 2020 · 7 comments
Closed

[v6] Disable React.useTransition before cutting stable #7308

gaearon opened this issue May 4, 2020 · 7 comments

Comments

@gaearon
Copy link
Contributor

gaearon commented May 4, 2020

Hey folks!

Noticed that v6 has this feature check:

https://github.com/ReactTraining/react-router/blob/5bef342de8fe3a7c132edf9cbab1464fda840399/packages/react-router/index.js#L172-L173

While this is exciting and is something we'll definitely want after useTransition is stable, it is really important that the v6 stable release does not ship with this check.

The reason is that useTransition API itself is still not finalized. For example, the config might move into the useTransition call. The tuple item order may change.

If React Router 6 goes stable with React.useTransition || polyfill, the moment we add React.useTransition as a stable API, all existing React Router 6 apps will switch to it automatically. So we would become locked into our current signature.

As a result, we may have to end up renaming useTransition to avoid a breaking change. Similar to Array.prototype.contains -> Array.prototype.includes and global -> globalThis. It would be nice if we could avoid this.

I'm not sure what's the best strategy if you'd like this to work with experimental React releases in the meantime. We can probably figure something out though.

Thank you!

@acdlite
Copy link
Contributor

acdlite commented May 4, 2020

What React will probably do is start prefixing all our experimental APIs again. Even if they only exist in the Experimental releases.

When we added the Experimental releases, we figured it was ok to start shipping un-prefixed experiments there, since they don't affect the main, stable release channel. But we hadn't really considered that third party projects would use feature detection in their stable releases. I can see why it seems harmless, though, so it's not really your fault. To make feature detection less tempting, looks like we're going to start prefixing again :)

@acdlite
Copy link
Contributor

acdlite commented May 4, 2020

Also I know v6 isn't stable yet, just made us realize that this could easily happen in some other project. Or if y'all accidentally forgot to remove it before the stable release.

@timdorr
Copy link
Member

timdorr commented May 4, 2020

We're still a ways out from even going beta (M+R are focused on Remix right now), but I'll make sure this gets swapped out later.

How should we be handling this polyfill? We can restrict a certain react version range from matching our peerdeps. Or we could just move up the minimum compatible version to correspond with the API release. Do you plan on majoring when this one is finalized, or keeping it in a minor?

@mjackson
Copy link
Member

mjackson commented May 4, 2020

I think the best strategy for us right now is probably just to back out anything to do with useTransition and move it into our own "experimental" release channel until upstream is stable.

Using the unstable_ prefix is a great idea, @acdlite 👍

@acdlite
Copy link
Contributor

acdlite commented May 5, 2020

For reference: facebook/react#18825

mjackson added a commit that referenced this issue May 7, 2020
- Moved history.listen calls into BrowerRouter, HashRouter, and
  MemoryRouter components and added <Router location> prop
- Use useLayoutEffect cleanup callback to teardown the listener
- Removed useTransition shim and timeout props. Will integrate this
  later in a new "experimental" release channel

Fixes #7195
Fixes #7308
@mjackson
Copy link
Member

The useTransition polyfill was removed in 89b7280, so I'm going to close this. I'm going to setup an experimental release channel that people can use if they'd like to get that behavior. When the useTransition API goes stable, we'll probably just cut a minor release that adds support for it.

@Hypnosphi
Copy link

React 18 is now released with a stable useTransition API. @mjackson do you consider bringing it back?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants