React-Native app to display cryptocurrency API data
Tutorial code from Fazt Code - see 👏 Inspiration below
Note: to open web links in a new window use: ctrl+click on link
Cryptocurrency data from the CoinGecko API and does not require an API key
React useEffect hook used for data fetching
React useState hook used to initialise & update coins, refeshing and search states
Run npm i to install dependencies
npm install -g expo-cli --force to install Expo CLI globally (force option may not be required)
Run npm start to start expo on a localhost port
See package.json for the npm commands to create build files etc.
Android Studio has to be installed and set up then the AVD Manager is run from the Configure menu
💻 Code Example by Fazt Code
Code by Fazt Code to display Cryptocurrency data. Includes ternery expression to show price change data in green or red
const CoinItem = ( { coin } ) => (
< View style = { styles . containerItem } >
< View style = { styles . coinName } >
< Image source = { { uri : coin . image } } style = { styles . image } />
< View style = { styles . containerNames } >
< Text style = { styles . text } > { coin . name } </ Text >
< Text style = { styles . textSymbol } > { coin . symbol } </ Text >
</ View >
</ View >
< View >
< Text style = { styles . textPrice } > ${ coin . current_price } </ Text >
< Text
style = { [
styles . pricePercentage ,
coin . price_change_percentage_24h > 0
? styles . priceUp
: styles . priceDown ,
] }
>
{ coin . price_change_percentage_24h . toFixed ( 2 ) } %
</ Text >
</ View >
</ View >
) ;
Expo bar code used to connect mobile to project. The Expo framework is easy to use.
Android Studio simulation on mobile device
Status: Working
To-do: Nothing.