Methods only accessible from Communications.default, not Communications when using old styled import
See original GitHub issueEdit: Quick answer -> using an old styled import require('...') can cause this behavior.
I just installed this plugin, I am using version 2.1.0
I am running this on the IOS simulator with React Native 0.28.0, the docs say to just call:
Communications.web(...
but in order for it to work, I need to call it this way (discovered this through debugging):
Communications.default.web(...
I believe this was introduced in this commit https://github.com/anarchicknight/react-native-communications/commit/460c7d8dc2123d0efaedd90a58ced0e6f705cff9
when the last line of AKCommunications.js
was changed from module.exports = communication;
to export default communication;
I’m not great with es6 yet, so the above is an educated guess. This isn’t a big issue, but I think it should either be changed back to match the documentation, or update the documentation.
Hopefully this helps, I’ll try to respond as promptly as possible but I am a very busy person (aren’t we all?) p.s. If I end up being right that that’s the issue, I can make a PR to get my hands in this repo. Thanks for open sourcing it!
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
cheers.
I definitely want to read up on the mixing of the old and new style though and find out if there are ways around it etc, and if not will update the docs to emphasise using the new style import
I have made some changes to how the Communications object and individual methods are exported.
It seems to work for me now when using old & new styles
e.g. var Communications = require(‘react-native-communications’) or import Communications from ‘react-native-communications’
will now both work when calling Communications.web(‘http://www.github.com’) etc
The ability to import single methods will also be available
e.g. import { web } from ‘react-native-communications’ which can be called just as web(‘http://www.github.com’)
The updated version should be committed in the next couple of days.