Skip to content
This repository has been archived by the owner on Dec 15, 2018. It is now read-only.

Fragments can't access this.context #191

Closed
elisechant opened this issue Jun 20, 2017 · 12 comments
Closed

Fragments can't access this.context #191

elisechant opened this issue Jun 20, 2017 · 12 comments

Comments

@elisechant
Copy link

elisechant commented Jun 20, 2017

Steps to reproduce

  1. download this repo, and open demo files.
  2. npm install -S redux-little-router
  3. open demo/client/demo.js:6. change this line:

import { Link, Fragment } from '../../src'; to:

import { Link, Fragment } from 'redux-little-router;

  1. Run the demo in browser

This error is visible in the console:

Uncaught TypeError: Cannot read property 'store' of undefined
    at RelativeFragment.render (main.js:30478)
    at main.js:15901
    at measureLifeCyclePerf (main.js:15180)
    at ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext (main.js:15900)
    at ReactCompositeComponentWrapper._renderValidatedComponent (main.js:15927)
    at ReactCompositeComponentWrapper.performInitialMount (main.js:15467)
    at ReactCompositeComponentWrapper.mountComponent (main.js:15363)
    at Object.mountComponent (main.js:7901)
    at ReactDOMComponent.mountChildren (main.js:14493)
    at ReactDOMComponent._createInitialChildren (main.js:11555)
@baebb
Copy link
Contributor

baebb commented Jun 20, 2017

NPM's stored package is broke?

I built & tested dist-min, dist-dev, lib and was able to get demo running fine, bar this unrelated warning from build-dist-min:

warning.js:36 Warning: Failed context type: Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types
    in r (created by Connect(r))
    in Connect(r) (created by Demo)
    in div (created by Demo)
    in Demo (created by Connect(Demo))
    in Connect(Demo)
    in Provider

@EmrysMyrddin
Copy link

Yes, NPM's package is broken. I have manually compiled it in my project and it solved the problem...

@tomciopp
Copy link

I am running into a similar issue with Link @justrossthings @EmrysMyrddin any tips for troubleshooting? I've also noticed that the code that breaks has been changed to remove the reference to context in the last few commits, is there any chance that a patch version can be released?

@therealpineda
Copy link

@EmrysMyrddin or @justrossthings how does one manually compile the npm package? 😅

@shepmaster
Copy link

shepmaster commented Jun 21, 2017

I believe the problem is that you are reading masters documentation but using the released version 13.2.0. You can see the documentation at https://github.com/FormidableLabs/redux-little-router/tree/v13.2.0. Specifically, I needed to wrap my app in <RouterProvider>

  <Provider store={store}>
+    <RouterProvider store={store}>
       <MyApp />
+   </RouterProvider>
  </Provider>

@baebb
Copy link
Contributor

baebb commented Jun 22, 2017

@therealpineda @tomciopp you can pull the redux-little-router (RLR) repo then run yarn install && yarn build-dist. You should find a dist folder in the RLR root folder with RLR.min.js

@shepmaster I thought 13.2 had removed RouterProvider?
#189

@shepmaster
Copy link

@justrossthings looking at the README for 13.2.0 I linked to, there's an entire section describing RouterProvider, and the code is still there.

@tptee
Copy link
Contributor

tptee commented Jun 22, 2017

I merged README updates for an unreleased PR 🤦‍♂️ I'll cut a release with the updates (which does remove RouterProvider)

@elisechant
Copy link
Author

@tptee can you publish 14.0.0 to npm as well?

In the meantime I can confirm that @shepmaster's snippet about using <RouterProvider is a valid workaround for now, but it is pretty ugly:

ReactDOM.render(
  <Provider store={store}>
    <RouterProvider store={store}>
      <Root />

@dskoda1
Copy link

dskoda1 commented Jun 28, 2017

Getting the documentation in sync would be nice, I banged my head against my computer for a day or two before finding this.

I also think having things crucial to initial setup like the RouterProvider was for 13.2 probably should've been higher up in the documentation - it was all the way at the bottom. Just thoughts going forward.

@tptee
Copy link
Contributor

tptee commented Jul 3, 2017

Sorry about the delay, v14 is out and the docs are in sync!

@tptee tptee closed this as completed Jul 3, 2017
@therealpineda
Copy link

never thanked you all. im getting around to using this again in a project soon and very grateful for your help and work here 👍 👍 👍 ❤️ @tptee @shepmaster @justrossthings @elisechant

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

No branches or pull requests

8 participants