Driversnote-Dev / react-native-kontaktio

React Native (iOS and Android) library for Kontakt.io beacons (and all other beacons)
MIT License
112 stars 48 forks source link

const connect already defined #39

Closed pashute closed 5 years ago

pashute commented 5 years ago

I have

 import { connect } from 'react-redux';

And then:

import Kontakt from 'react-native-kontaktio';
const {  connect, configure, disconnect. startScanning, setBeaconReagons ... 

But I get an ESLint error: connect is already defined. And rightly so, no?

I tried

import { connect as connectKontakt, configure, disconnect, startScanning, setBeaconReagons...

But that gives me: Possible Unhandled Promise Rejection (reactNativeKontaktio.connect) is not a function.

What should/can I do?

Please see https://stackoverflow.com/questions/51589676/es6-how-to-import-already-defined-in-another-js-package

ca057 commented 5 years ago

Right, having two variables named connect shouldn't work. Regardless of that, can you give some more context - eslint version & setup?

Haven't tried it locally, but what might work is something like the following (renaming the property you destructure from the Kontakt object):

import { connect } from 'react-redux';
import Kontakt from 'react-native-kontaktio';

const { connect: connectKontakt, configure /* ... all the other things you need from RNKontakt */ } = Kontakt;
pashute commented 5 years ago

Thank you!!

Meanwhile I changed the other (redux) constant by calling

import { connect as reduxConnect } from 'react-redux';

and that worked. But had to change my redux code a tiny bit.