Nginx Container for React with Docker Compose

Nginx Container for React with Docker Compose

Tiempo de lectura: < 1 minutoToday I’m going to share a container setup for React based on Nginx. To do this, we are going to create this docker-compose.yml Now we are going to create our Dockerfile Finally, we will create the necessary folders: The nginx.conf file must contain: Remember that the React distribution folder generated with Vite is inside dist, … Read more

Create Development Build with React Vite

Create Development Build with React Vite

Tiempo de lectura: < 1 minutoToday we are going to learn how we can generate a development build with React Vite. This will generate the dist folder with development configuration. To do this, we need to go to the package.json file and add this command inside “scripts”: { Returns only the HTML translated, without any additions. npm build-dev This way … Read more

Implementing Vitest in a React Environment with Vite for Unit Tests

Implementing Vitest in a React Environment with Vite for Unit Tests

Tiempo de lectura: 2 minutosToday we are going to learn how we can install Vitest in a React environment with Vite. First, we will install Vitest: npm install -D vitest After we will install the necessary libraries: npm install vitest @testing-library/react @testing-library/jest-dom –save-dev Now let’s create the directory structure for the tests, outside our src folder: And within components, … Read more

Adding a Theme in React to Change Element Colors and Text Font.

Adding a Theme in React to Change Element Colors and Text Font.

Tiempo de lectura: < 1 minutoFor this tutorial, we will use Material UI. First, we install the necessary dependencies: npm install @mui/material @emotion/react @emotion/styled Now, let’s create our theme by creating a file named theme.tsx (I use TypeScript, you can create it in JavaScript) In my case, I have set Roboto as the fontFamily and the colors to Teal. Now, … Read more

Integrating Unit Tests with Jest in React

Integrating Unit Tests with Jest in React

Tiempo de lectura: 2 minutosToday we are going to learn how we can integrate tests with Jest that allow us to test the React components created. The first thing we have to do is install Jest: npm install –save-dev jest Install testing-library/jest-dom: npm install –save-dev @testing-library/jest-dom We installed ts-jest npm install –save-dev ts-jest We installed: npm install –save-dev babel-jest … Read more

Adding GDPR European Ad Consent Message with React Native Google Mobile Ads (ADMOB) using Expo

Adding GDPR European Ad Consent Message with React Native Google Mobile Ads (ADMOB) using Expo

Tiempo de lectura: 2 minutosToday we are going to learn how we can add the mandatory ad consent message to comply with GDPR. The first thing we need to do is to have our message set up: https://devcodelight.com/mensaje-consentimiento-conforme-rgpd-para-admob/ NOTE: I am using version 12.2.0 of react-native-google-mobile-ads at least (https://github.com/invertase/react-native-google-mobile-ads) Once configured, let’s go to android/app/proguard-rules.pro and add: -keep class … Read more

Implementing Google Consent for GDPR with React Native

Implementing Google Consent for GDPR with React Native

Tiempo de lectura: < 1 minutoToday we are going to learn how we can implement the GDPR consent message with React Native. Lets install the following library (https://www.npmjs.com/package/@ulangi/react-native-ad-consent) npm install @ulangi/react-native-ad-consent –save <p.Now let’s add this key in info.plist of iOS: <p.Now we open AndroidManifest.xml in case of Android. And add: And now we create our component called consentAdmob.ts To … Read more

Failed to connect with the project in React Native

Failed to connect with the project in React Native

Tiempo de lectura: 2 minutosI tried to run an application developed in React Native on an Android device, and I encountered the following error. To solve it, I went to the network and Internet settings of my computer, after clicking on ‘Connection status’ as shown in the following image. We are now going to click where we are connected … Read more