Wildsong / ol-react

React bindings for OpenLayers
MIT License
8 stars 2 forks source link

layerCollection not defined #5

Closed wuhland closed 5 years ago

wuhland commented 5 years ago

I really like what where you are going with this and would love to make it work for my project. I tried building with ol5 (I need to use ol5) but keep running into an issue where CollectionContext is failing.

The specific error I have been getting is: Uncaught TypeError: Cannot read property 'push' of undefined at tile.js:12 at commitHookEffectList (react-dom.development.js:19986) at commitPassiveHookEffects (react-dom.development.js:20016) at HTMLUnknownElement.callCallback (react-dom.development.js:347)and at Object.invokeGuardedCallbackDev (react-dom.development.js:397) at invokeGuardedCallback (react-dom.development.js:454) at flushPassiveEffectsImpl (react-dom.development.js:22868) at unstable_runWithPriority (scheduler.development.js:643) at runWithPriority$2 (react-dom.development.js:11305) at flushPassiveEffects (react-dom.development.js:22841)

undefinined in this case referring to layerCollection from const layerCollection = useContext(CollectionContext); in the Tile component. I dont think this has anything to do with ol5. Not sure what is going on there.

brian32768 commented 5 years ago

I screwed up, it's not because of ol5. I will fix it. I have to, tomorrow morning - it won't build for me either right now.

I switched to ol6 and made a 100 changes and then switched back to ol5 and found that there was an issue with it re-rendering the map on every mouse move. I haven't tried to figure out why it does this. There is currently one line of code that makes ol5 incompatible, in graticule.js, because they changed where the graticule code lives in OL. There is no doubt a way to detect ol5 vs ol6 and build the right way accordingly but I don't know what it is yet.

On Sun, Sep 22, 2019 at 5:13 PM David Saeger notifications@github.com wrote:

I really like what where you are going with this and would love to make it work for my project. I tried building with ol5 (I need to use ol5) but keep running into an issue where CollectionContext is failing.

The specific error I have been getting is: Uncaught TypeError: Cannot read property 'push' of undefined at tile.js:12 at commitHookEffectList (react-dom.development.js:19986) at commitPassiveHookEffects (react-dom.development.js:20016) at HTMLUnknownElement.callCallback (react-dom.development.js:347)and at Object.invokeGuardedCallbackDev (react-dom.development.js:397) at invokeGuardedCallback (react-dom.development.js:454) at flushPassiveEffectsImpl (react-dom.development.js:22868) at unstable_runWithPriority (scheduler.development.js:643) at runWithPriority$2 (react-dom.development.js:11305) at flushPassiveEffects (react-dom.development.js:22841)

undefinined in this case referring to layerCollection from const layerCollection = useContext(CollectionContext); in the Tile component. I dont think this has anything to do with ol5. Not sure what is going on there.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Wildsong/ol-react/issues/5?email_source=notifications&email_token=AAP6RRBEAXEXX2QWWVIP2O3QLACZNA5CNFSM4IZFHNMKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HM5LJFQ, or mute the thread https://github.com/notifications/unsubscribe-auth/AAP6RRHKB2PQ4IRFDRCXMJDQLACZNANCNFSM4IZFHNMA .

-- Brian Wilson tel:707-827-0003

brian32768 commented 5 years ago

fixed it

wuhland commented 5 years ago

Thanks!