I\'m stuck on a problem in a react-native project. I\'m trying to do a general require file, where I export all my modules. After that I would like to require only my \"requ
This is way old, but the record needs to be corrected. Require isn't async. You can tell this easily by inspecting the object returned (not a promise).
Re-exporting in ES6 is simple.
For example:
export * from './types';
export { default as ApiClient } from './ApiClient';
So I'm posting my own answer in case someone else has the same problem.
In a syntax like this the required files are getting loaded synchronously. So if the component's build is faster than requiring files, this problem happens. Either make your components load lazy when you need them or use es6 import syntax like this (import loads asynchronously):
import React from 'react-native'
cheers!
Add @providesModule moduleName
in your file header comment. And you can import using require('moduleName') other place in your project.
See this issue.
BTW, how come that such a amazing feature never documented anywhere ?