react-router icon indicating copy to clipboard operation
react-router copied to clipboard

IE8 support

Open AdamGelderAeriandi opened this issue 11 years ago • 18 comments

I recently upgraded the react router from 1.0.0-rc1 to 1.0.0-rc3 which breaks compatibility with IE8 with the following error: Invariant Violation: ReactCompositeComponent.getChildContext(): childContextTypes must be defined in order to use getChildContext()

I have had to roll back to 1.0.0-rc1 for the moment.

Any Thoughts?

Many Thanks

Adam

AdamGelderAeriandi avatar Oct 19 '15 13:10 AdamGelderAeriandi

Do you have any more details on where this error is being thrown?

taion avatar Oct 19 '15 16:10 taion

provide more details and we will reopen. Hard to help with that at the moment.

knowbody avatar Oct 22 '15 14:10 knowbody

hey guys, I'm at a company that also has to support ie8 (government man...) and I'm 99% sure I know what's going on. Basically you can't do things like https://github.com/rackt/react-router/blob/master/modules/Router.js#L30. where you define static props right on the class, instead you have to do things like this: https://github.com/rackt/react-redux/pull/135/files where you just put the props at the bottom. It's really simple and I can open a PR to fix it. I'll letcha know how it goes! (the problem is that object.defineProperty it un-polyfillable and that particular interaction needs object.defineProperty.

mattydoincode avatar Nov 12 '15 19:11 mattydoincode

That's not correct - the code above is actually not valid in any browser; it runs because we transpile it through Babel into legal code.

taion avatar Nov 12 '15 19:11 taion

I'm well aware of the transpiler being used. When you use static properties, the transpiler (babel) uses defineProperty, when you don't have static props, it doesn't use defineProperty. Check my PR that I linked for a full discussion.

mattydoincode avatar Nov 12 '15 19:11 mattydoincode

sorry this is the discussion: https://github.com/rackt/react-redux/issues/133

mattydoincode avatar Nov 12 '15 19:11 mattydoincode

My bad! I wasn't aware it was a consequence of that specific Babel interaction.

taion avatar Nov 12 '15 19:11 taion

To clarify - this is broken even when using es5-shim?

taion avatar Nov 12 '15 19:11 taion

Yup, Completely broken and unfixable. Class properties are still experimental (https://babeljs.io/docs/plugins/). I have a PR that I'm about to setup that removes them completely. Not sure if there is a way to lint against this though as I couldn't find a static properties type rule...

On Thu, Nov 12, 2015 at 2:54 PM, Jimmy Jia [email protected] wrote:

To clarify - this is broken even when using es5-shim?

— Reply to this email directly or view it on GitHub https://github.com/rackt/react-router/issues/2314#issuecomment-156216539 .

mattydoincode avatar Nov 12 '15 19:11 mattydoincode

@mattydoincode

I'd drop up to Babel stage 1 from stage 0 if you want to enforce the non-use of class properties.

Although I think Babel 6 moved them up to the stage 1 preset, so worth tacking a note somewhere.

taion avatar Nov 12 '15 20:11 taion

You can also blacklist the specific Babel transformation if you want to be more explicit.

taion avatar Nov 12 '15 20:11 taion

I'm still researching locally to see exactly how ie8 is responding to everything. Will keep you posted! Just want to make sure I can back everything up with real world results.

On Thu, Nov 12, 2015 at 3:06 PM, Jimmy Jia [email protected] wrote:

@mattydoincode https://github.com/mattydoincode

I'd drop up to Babel stage 1 from stage 0 if you want to enforce the non-use of class properties.

Although I think Babel 6 moved them up to the stage 1 preset, so worth tacking a note somewhere.

— Reply to this email directly or view it on GitHub https://github.com/rackt/react-router/issues/2314#issuecomment-156219537 .

mattydoincode avatar Nov 12 '15 20:11 mattydoincode

in my project say "setter & getter is not support in this javascript engine" and i try to read your code. i find this is case by "export * from "./xx" some code like this.

gagayang avatar Aug 25 '16 06:08 gagayang

https://phabricator.babeljs.io/T7322

SimenB avatar Aug 25 '16 07:08 SimenB

hello you mean this can fix the issues? @SimenB

gagayang avatar Aug 25 '16 07:08 gagayang

But we refer to the use of the compiled lib file, is that we want to compile the webpack which includes nodo_modules?@SimenB

gagayang avatar Aug 25 '16 07:08 gagayang

If that issue is addressed, the router would be compiled in an IE8 compatible way. It's not something you can fix on your end, either the router has to export in some other way, or Babel need to change how it's compiled.

I haven't tried using the router with IE8, but you can probably import directly from lib/ (unsure how supported it is, so you might want to lock down you version of the router), to avoid the unsupported code in the entry point.

SimenB avatar Aug 25 '16 07:08 SimenB

thank you very much for your help. i have try to babel compiled by IE8 way. but it still not work. it may be other npm class libraries made. i think this too many libraries not support Ie8.

i from china ,my english is poor, thanks agan.

gagayang avatar Aug 25 '16 07:08 gagayang