This guide will help you set up a React Native weather app using TailwindCSS. Follow the steps below to get your development environment ready.
First, you need to install Node.js and npm. Download the prebuilt installer from the Node.js website and follow the installation instructions.
Open your terminal and run the following command to create a new Expo app using the template:
npx create-expo-app --templateChange to your app directory with the following command:
cd yourAppNameTo use Heroicons in your app, install react-native-heroicons and react-native-svg:
npm install react-native-heroicons react-native-svgNext, install react-n ative-progress to display progress indicators in your app:
npm install react-native-progressInstall axios to make HTTP requests to fetch weather data:
npm install axiosa. Install NativeWind
npm install nativewindb. Install TailwindCSS Install TailwindCSS as a development dependency:
npm install --save-dev [email protected]c. Initialize TailwindCSS Run the following command to create a TailwindCSS configuration file:
npx tailwindcss initd. Configure TailwindCSS
Replace the contents of tailwind.config.js with the following configuration:
// tailwind.config.js
module.exports = {
content: ["./App.{js,jsx,ts,tsx}", "./screens/**/*.{js,jsx,ts,tsx}"],
theme: {
extend: {},
},
plugins: [],
}
e. Configure Babele. Configure Babel
Replace the contents of babel.config.js with the following configuration:
// babel.config.js
module.exports = function (api) {
api.cache(true);
return {
presets: ["babel-preset-expo"],
plugins: ["nativewind/babel"],
};
};
Finally, start the Expo development server with the following command:
npx expo startIf you need to use the tunnel option, use:
npx expo start --tunnel