Closed SaiShangAI closed 3 years ago
Hi @SaiShangAI, could you paste here your code where you import the library and use setRegion
function?
hi @ziyaddin I import the library and would like to set the region in a file like this:
import React from 'react';
import {
GoogleMap,
InfoWindow,
KmlLayer,
Marker,
withGoogleMap,
withScriptjs
} from 'react-google-maps';
import Geocode from 'react-geocode';
import * as PropTypes from 'prop-types';
Geocode.enableDebug();
Geocode.setRegion('cn')
Geocode.setApiKey('XXXXXXXXXXXXXX');
......
hi @ziyaddin it seems like the function setRegion
is not defined
@SaiShangAI could you install @types/react-geocode package and see if it works after that?
hi @ziyaddin nope, doesn't work
@SaiShangAI where is this type file located? Can you remove it?
@SaiShangAI the type, you are using, is wrong. The correct one is @types/react-geocode. You should somehow remove the wrong one.
hi @ziyaddin I removed the react-geocode and install @types/react-geocode. But When I import import Geocode from '@types/react-geocode'
, the terminal show Module is not found. So I would like to ask If my importing is right? many thanks
Module not found: Can't resolve '@types/react-geocode'
@SaiShangAI you should import Geocode not from @types/react-geocode
but react-geocode
:
import Geocode from 'react-geocode';
@types/react-geocode
will help you with types by suggesting them to you. No need to import this package into your code.
Please, try and inform me if it works.
hi @ziyaddin I installed @types/react-geocode
and react-geocode
. But still I don't know how to make Geocode link to the right types.
@SaiShangAI where is the old type file, you showed me via image above, located? By default, each library tries to link to its own @types/bla-bla-bla
package.
hi @ziyaddin the Type definitions for react-geocode 0.2. I installed the version is 0.1.2. Now I use the newest react-geocode version. It works. Many thanks🙏 for your help. Really appreciate.
@SaiShangAI you're welcome.
hi @shukerullah I got the error when I want to ser my region. Could you help me with the issue? Many thanks