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

65
Views
Set colours of React Native App through API response

It's basically Web and Mobile app. The user will be able to customise the theme on the web. When he logs in to the mobile, he will get the colour scheme along with the response object (of login API) Since I cannot call the login API again, so I am storing the colours in AsyncStorage. In my application, I have a file which I use to set colours of the whole app. Here is the code:

import AsyncStorage from '@react-native-async-storage/async-storage';
let themeColorDark = "#123A43";
let themeColorLight = "#76AEB5";
let themeActiveColor = "#206775";

const getColors = async () => {
    themeActiveColor = await AsyncStorage.getItem('primary');
    themeColorDark = await AsyncStorage.getItem('dark');
    themeColorLight = await AsyncStorage.getItem('light');
    console.log(themeActiveColor, themeColorDark, themeColorLight);
    // the results of the console: #610f0f #e2b1b1 #e7d5d5
    // while the actual colors: #206775 #123A43 #76AEB5
}
getColors();

export default {
    themeColorDark: themeColorDark,
    themeColorLight: themeColorLight,
    themeActiveColor: themeActiveColor,
};

The problem is, the result of the console is correct. But actual colours are which I initialised. I am new to React Native, so any help or alternative solution would be highly appreciated.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think you had saved some value colour code in your AsyncStorage before. you must update your values first in AsyncStorage. use useState to keep tracking of updating data and set new values in your AsyncStorage and you're good to go

about 4 years ago · Juan Pablo Isaza 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!