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

Add back React.__spread and make it warn #6444

Merged
merged 2 commits into from Apr 8, 2016

Conversation

Projects
None yet
@zpao
Copy link
Member

commented Apr 7, 2016

This API was removed because it was undocumented and existed solely for our JSXTransformer/react-tools, which haven't been supported for a year. However it turns out TypeScript is still using this API in their TSX compilation and it kind of sucks to break people who want to upgrade React but not the rest of their toolchain.

Note: this doesn't quite (read at all) work with the Object.assign -> object-assign transform I wrote so would need to fix that too.

Revert "Merge pull request #6431 from sebmarkbage/killspread"
This reverts commit a37e4e9, reversing
changes made to 411951d.
@sebmarkbage

This comment has been minimized.

Copy link
Member

commented Apr 7, 2016

Can we make it say something about TypeScript and JSTransformer specifically so people know how to upgrade?

warning(
warned,
'React.__spread is deprecated and should not be used. Use ' +
'Object.assign directly or another helper function with similar semantics'

This comment has been minimized.

Copy link
@sophiebits

sophiebits Apr 7, 2016

Collaborator

nit: add trailing period

@KyleAMathews

This comment has been minimized.

Copy link
Contributor

commented Apr 7, 2016

Coffee-React uses it as well fwiw https://github.com/jsdf/coffee-react#spread-attributes

'Object.assign directly or another helper function with similar semantics'
);
warned = true;
return Object.assign.apply(Object, arguments);

This comment has been minimized.

Copy link
@zpao

zpao Apr 7, 2016

Author Member

Going to make this Object.assign.apply(null, arguments) (shouldn't matter but makes more sense when compiling to use object-assign. `_assign.apply(null, arguments)

@gaearon

This comment has been minimized.

Copy link
Member

commented Apr 7, 2016

At least these days we know how to name things.

@@ -65,6 +81,9 @@ var React = {
DOM: ReactDOMFactories,

version: ReactVersion,

// Hook for JSX spread, don't use this for anything else.

This comment has been minimized.

Copy link
@kuon

kuon Apr 7, 2016

Maybe state in the comment that this is deprecated and evil to use?

@sebmarkbage

This comment has been minimized.

Copy link
Member

commented Apr 8, 2016

I originally confused this with https://github.com/facebook/react-native/blob/master/Libraries/ReactNative/ReactNative.js#L96 and got overexcited to kill this too. I should've deprecated it first.

@zpao zpao force-pushed the zpao:re__spreadwarn branch 2 times, most recently from efc4042 to 7072559 Apr 8, 2016

@zpao zpao added this to the 15.0.1 milestone Apr 8, 2016

@zpao

This comment has been minimized.

Copy link
Member Author

commented Apr 8, 2016

Can we make it say something about TypeScript and JSTransformer specifically so people know how to upgrade?

Better? I figured we could just link to a page on the wiki that discusses typescriupt and coffeescript specifically instead of putting it in the warning.

@sebmarkbage

This comment has been minimized.

Copy link
Member

commented Apr 8, 2016

👍

@facebook-github-bot

This comment has been minimized.

Copy link

commented Apr 8, 2016

@zpao updated the pull request.

@zpao zpao force-pushed the zpao:re__spreadwarn branch from 7072559 to fc1cfb6 Apr 8, 2016

@zpao zpao merged commit 516c1d8 into facebook:master Apr 8, 2016

1 check was pending

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
@zpao

This comment has been minimized.

Copy link
Member Author

commented Apr 8, 2016

Just going to point that fb.me url here for the time being. We can change it later, but I'm optimizing for the path which gets me to a drink fastest.

@facebook-github-bot

This comment has been minimized.

Copy link

commented Apr 8, 2016

@zpao updated the pull request.

zpao added a commit to zpao/react that referenced this pull request Apr 8, 2016

Merge pull request facebook#6444 from zpao/re__spreadwarn
Add back React.__spread and make it warn
(cherry picked from commit 516c1d8)
@glenjamin

This comment has been minimized.

Copy link
Contributor

commented Apr 8, 2016

Seeing a few people pop up in support channels with this issue - might be worth adding a note to the v15 announcement?

Medium-term: I wonder if there's a good way to automatically check compatibility with widely used downstream projects against RCs. I know really that should be downstream's responsibility - but I wonder if there's anything React's team/community can do to help.

@m4tthumphrey

This comment has been minimized.

Copy link

commented Apr 8, 2016

This bit me on the bum when I just upgraded to 15.0. I get that it's been deprecated/removed but even after reading this thread I'm a confused on what I need to do fix it?

Edit: I think I need to point out that I'm not using React.__spread myself; my render method looks like

return (
  <input type="text" value={value} onChange={onChange} className={classeNames} {...other} />
);

and the ...other transpiled to

React.spread(..)

Does this make a difference?

@gaearon

This comment has been minimized.

Copy link
Member

commented Apr 8, 2016

@m4tthumphrey

This is not a problem with your code. It's a problem with whatever tool you use to compile JSX.

If you are using react-tools to compile JSX, please switch to Babel. That project was unsupported for more than a year.

The fix will be out today because TypeScript still depends on it but this method is still deprecated so please try to migrate to tools that don't use it.

@m4tthumphrey

This comment has been minimized.

Copy link

commented Apr 8, 2016

@gaearon Thanks Dan, thats what I thought. Forgive me but how do I switch from using react-tools to babel? I already tried this morning after reading through the blog post but didn't really know what I was doing..?

@gaearon

This comment has been minimized.

Copy link
Member

commented Apr 8, 2016

How do you compile JSX?

@m4tthumphrey

This comment has been minimized.

Copy link

commented Apr 8, 2016

@gaearon

webpack loaders..

module.exports = {
  entry: './js/app.js',
  output: {
    filename: './bundle.js',
    path: './static/'
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'jsx?harmony'
      },
      {
        test: /\.(png|jpg|gif)$/,
        loader: 'url?limit=8192'
      },
      {
        test: /\.css$/,
        loader: 'style!css'
      }
    ]
  }
};
@gaearon

This comment has been minimized.

Copy link
Member

commented Apr 8, 2016

You are using jsx-loader which uses deprecated react-tools. Replace it with babel-loader. Then configure Babel to use es2015 and react presets and you should be good.

@m4tthumphrey

This comment has been minimized.

Copy link

commented Apr 8, 2016

Ahh I see, great than you Dan.

On 8 April 2016 at 16:01, Dan Abramov notifications@github.com wrote:

You are using jsx-loader which uses deprecated react-tools. Replace it
with babel-loader. Then configure Babel to use es2015 and react presets
and you should be good.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#6444 (comment)

@dsifford

This comment has been minimized.

Copy link

commented Apr 10, 2016

@gaearon

You are using jsx-loader which uses deprecated react-tools. Replace it with babel-loader. Then configure Babel to use es2015 and react presets and you should be good.

I'm doing these things now and still getting the depreciation warning. Is this to be expected until Typescript fixes whatever internals they need to fix? Or should I investigate further?

@gaearon

This comment has been minimized.

Copy link
Member

commented Apr 11, 2016

I'm doing these things now and still getting the depreciation warning. Is this to be expected until Typescript fixes whatever internals they need to fix?

If you use TypeScript, yes, you will need for them to release the fix.

@dsifford

This comment has been minimized.

Copy link

commented Apr 11, 2016

Ok great that's what I assumed. Thanks for the clarification 👍

@DanielRosenwasser

This comment has been minimized.

Copy link
Contributor

commented Apr 12, 2016

As a heads up, this should now be fixed in TypeScript 1.8.10.

@zpao

This comment has been minimized.

Copy link
Member Author

commented Apr 12, 2016

Thanks @DanielRosenwasser, I appreciate the quick turn around! Sorry for the surprise breakage.

@zpao zpao deleted the zpao:re__spreadwarn branch Apr 12, 2016

@DanielRosenwasser

This comment has been minimized.

Copy link
Contributor

commented Apr 12, 2016

No worries - I've been trying to keep a better eye on the activity of the repo since this all first went down. We really appreciate how quick the React team was to get a fix out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.