Uber H3 geoToH3 is not working in React Native

774 views Asked by At

I am developing simple grid location based application in React Native using Uber H3. I installed H3 by npm install h3-js. Then I created a file to read H3Index from latitude and longitude.

    import {geoToH3} from 'h3-js';
    const getH3Index = () => {
        const result = geoToH3(37.3615593, -122.0553238, 7);
        console.log(result);
    };

When I start to run my React Native application, app hangs on white screen(splash screen) and blocks the whole application. If I comment these lines, app works fine. If uncomment this line, both iOS and Android app is not working.

Any help would be much appreciated!

1

There are 1 answers

0
nrabinowitz On BEST ANSWER

Please see https://github.com/uber/h3-js/issues/35

This is likely due to a document is not defined error. See the issue thread for several possible workarounds, including this fork which is intended for React Native.