Skip to content

Commit

Permalink
compose menu: Use newly-standard "dynamic import" instead of "require".
Browse files Browse the repository at this point in the history
This reached Stage 4 in the TC39 process a few months ago:
  https://github.com/tc39/proposal-dynamic-import/

And we already have the Babel plugin for it enabled, via the
`metro-react-native-babel-preset` package.

So, use it to replace the nonstandard `require` borrowed from Node,
making it more visibly parallel to the usual static `import`.

Suggested-by: Anders Kaseorg <anders@zulipchat.com>
  • Loading branch information
gnprice committed Sep 11, 2019
1 parent c61702e commit 338036e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/compose/ComposeMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ class ComposeMenu extends PureComponent<Props> {
handleFilePicker = async () => {
// Defer import to here, to avoid an obnoxious import-time warning
// from this library when in the test environment.
// eslint-disable-next-line global-require
const DocumentPicker = require('react-native-document-picker').default;
const DocumentPicker = (await import('react-native-document-picker')).default;

let response;
try {
Expand Down

0 comments on commit 338036e

Please sign in to comment.