Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

123
Views
Promise objects not working in React Native project

First, I thought firebase functions were broken. Then, I tried to make a simple function that returns Promise. I put that to top-level index.js.

const testPromise = param => {
  console.log('return promise', param);
  return new Promise((resolve, reject) => {
    console.log('resolve promise');
    resolve('derp');
  });
};

testPromise('hede')
  .then(d => {
    console.log('resolved');
  })
  .catch(e => {
    console.log('e', e);
  });

AppRegistry.registerComponent(appName, () => App);

Console output:

return promise hede
resolve promise

See, there is no 'resolved' log nor error log.

I tried to change nodejs versions with nvm but no luck. I tried v12.5.0, v12.18.2, v15.6.0, v10.16.3. I tried like nvm use 12.5 && npm start

I've tried to create a new react-native project and I copied everything. Now, it works as expected. It is a solution for me but I didn't mark the question as solved because there is still a mystery, I couldn't figure why it doesn't work on the existing project.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

It seems that setting inlineRequires to false inside the metro.config.js file resolves the issue.

module.exports = {
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: false,
      },
    }),
  },
};

After making that change the output is:

return promise hede
resolve promise
resolved

Source: https://github.com/facebook/react-native/issues/31558#issuecomment-878342213

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!