<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vineetdixit Vns on Medium]]></title>
        <description><![CDATA[Stories by Vineetdixit Vns on Medium]]></description>
        <link>https://medium.com/@vineetdixit.vns?source=rss-a5e44f94615d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*cA6KfMjHN8EySL_U</url>
            <title>Stories by Vineetdixit Vns on Medium</title>
            <link>https://medium.com/@vineetdixit.vns?source=rss-a5e44f94615d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 05:53:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vineetdixit.vns/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Offline-First Architecture with WatermelonDB and MongoDB]]></title>
            <link>https://medium.com/@vineetdixit.vns/offline-first-architecture-with-watermelondb-and-mongodb-7efee1a09bb0?source=rss-a5e44f94615d------2</link>
            <guid isPermaLink="false">https://medium.com/p/7efee1a09bb0</guid>
            <category><![CDATA[offline]]></category>
            <category><![CDATA[watermelon]]></category>
            <category><![CDATA[sync]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[offline-first]]></category>
            <dc:creator><![CDATA[Vineetdixit Vns]]></dc:creator>
            <pubDate>Sun, 12 Jan 2025 16:30:09 GMT</pubDate>
            <atom:updated>2025-01-12T16:30:09.197Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*EYx0Dm0rSJ26NjcuUFlvhw.jpeg" /></figure><p>In today’s world, mobile apps are expected to provide seamless functionality, even in the absence of a reliable internet connection. Offline-first architecture has become a cornerstone for achieving this, especially in scenarios where users may have intermittent or no connectivity. This article explores how to implement an offline-first approach using <strong>WatermelonDB</strong> and <strong>MongoDB</strong>.</p><h3>What is Offline-First Architecture?</h3><p>Offline-first architecture ensures that an application remains functional without relying on a constant internet connection. Data is stored locally on the device and synchronized with the server when connectivity is restored. This approach enhances user experience, improves performance, and reduces server dependency.</p><h3>Tools for the Job</h3><p>To implement offline-first functionality, we’ll use the following tools:</p><ul><li><strong>WatermelonDB</strong>: A high-performance database optimized for React and React Native applications, designed to work offline and sync with a server.</li><li><strong>MongoDB</strong>: A NoSQL database known for its flexibility and scalability, suitable for backend data storage and synchronization.</li></ul><h3>Why WatermelonDB and MongoDB?</h3><p><strong>WatermelonDB</strong> is ideal for offline-first scenarios because it:</p><ul><li>Provides fast local storage.</li><li>Enables complex queries using a simple API.</li><li>Supports synchronization with remote servers.</li></ul><p><strong>MongoDB</strong> complements this by:</p><ul><li>Offering a flexible schema for storing data.</li><li>Providing robust synchronization capabilities through tools like Realm Sync or custom REST APIs.</li></ul><h3>Step-by-Step Implementation</h3><p>First, add Watermelon to your project:</p><pre>yarn add @nozbe/watermelondb<br><br># (or with npm:)<br>npm install @nozbe/watermelondb</pre><p>Install the Babel plugin for decorators if you haven’t already</p><pre>yarn add --dev @babel/plugin-proposal-decorators<br><br># (or with npm:)<br>npm install -D @babel/plugin-proposal-decorators</pre><p>Create a Folder name Database inside that folder create below files</p><p><strong>schema.js</strong></p><pre>import { tableSchema } from &#39;@nozbe/watermelondb&#39;;<br><br>export const taskSchema = tableSchema({<br>  name: &#39;tasks&#39;,<br>  columns: [<br>    { name: &#39;name&#39;, type: &#39;string&#39; },<br>    { name: &#39;is_completed&#39;, type: &#39;boolean&#39; },<br>    { name: &#39;created_at&#39;, type: &#39;number&#39; },<br>  ],<br>});</pre><p>model.js</p><pre>import { Model } from &#39;@nozbe/watermelondb&#39;;<br>import { field, date } from &#39;@nozbe/watermelondb/decorators&#39;;<br><br>export default class Task extends Model {<br>  static table = &#39;tasks&#39;;<br><br>  @field(&#39;name&#39;) name;<br>  @field(&#39;is_completed&#39;) isCompleted;<br>  @date(&#39;created_at&#39;) createdAt;<br>}</pre><p>database.js</p><pre>import SQLiteAdapter from &quot;@nozbe/watermelondb/adapters/sqlite&quot;<br>import { mySchema } from &quot;./schema&quot;<br>import { Database } from &quot;@nozbe/watermelondb&quot;<br>import userdata from &quot;./userdata&quot;<br>const adapter = new SQLiteAdapter({<br>    schema: taskSchema<br>})<br><br>export const database = new Database({<br>    adapter,<br>    modelClasses: [tasks],<br>    actionEnabled: true<br>})</pre><p>sync.js</p><pre>import { synchronize } from &#39;@nozbe/watermelondb/sync&#39;;<br><br>export async function syncDatabase(database) {<br>  await synchronize({<br>    database,<br>    pullChanges: async ({ lastPulledAt }) =&gt; {<br>      const response = await fetch(`http://localhost:3000/tasks?lastPulledAt=${lastPulledAt}`);<br>      const { tasks, timestamp } = await response.json();<br><br>      const changes = {<br>        tasks: tasks.map((task) =&gt; ({<br>          id: task._id,<br>          name: task.name,<br>          is_completed: task.is_completed,<br>          created_at: task.created_at,<br>          updated_at: task.updated_at,<br>        })),<br>      };<br><br>      return { changes, timestamp };<br>    },<br>    pushChanges: async ({ changes }) =&gt; {<br>      await fetch(&#39;http://localhost:3000/tasks&#39;, {<br>        method: &#39;POST&#39;,<br>        body: JSON.stringify(changes.tasks),<br>        headers: {<br>          &#39;Content-Type&#39;: &#39;application/json&#39;,<br>        },<br>      });<br>    },<br>  });<br>}</pre><p>For synchronization, you’ll need a backend. MongoDB provides several options for syncing, including Realm Sync. Alternatively, you can create a custom API.</p><p>Here’s how to set up basic synchronization:</p><p><strong>Backend API</strong></p><ol><li>Use <strong>Node.js</strong> and <strong>Express</strong> to create a simple API.</li><li>Install MongoDB and connect it to your server.</li></ol><pre>const express = require(&#39;express&#39;);<br>const mongoose = require(&#39;mongoose&#39;);<br><br>const app = express();<br>app.use(express.json());<br><br>// MongoDB Connection<br>mongoose.connect(&#39;mongodb://localhost:27017/offlineFirstDB&#39;, {<br>  useNewUrlParser: true,<br>  useUnifiedTopology: true,<br>});<br><br>// Schema and Model<br>const TaskSchema = new mongoose.Schema({<br>  name: String,<br>  is_completed: Boolean,<br>  created_at: Date,<br>  updated_at: Date,<br>});<br><br>const Task = mongoose.model(&#39;Task&#39;, TaskSchema);<br><br>// Utility: Get records updated since a timestamp<br>app.get(&#39;/tasks&#39;, async (req, res) =&gt; {<br>  const lastPulledAt = new Date(parseInt(req.query.lastPulledAt || &#39;0&#39;, 10));<br>  const tasks = await Task.find({ updated_at: { $gt: lastPulledAt } });<br>  res.json({ tasks, timestamp: Date.now() });<br>});<br><br>// Utility: Apply incoming changes<br>app.post(&#39;/tasks&#39;, async (req, res) =&gt; {<br>  const changes = req.body;<br><br>  // Process added or updated tasks<br>  if (changes.created) {<br>    for (const task of changes.created) {<br>      await Task.updateOne(<br>        { _id: task.id },<br>        {<br>          $set: {<br>            name: task.name,<br>            is_completed: task.is_completed,<br>            created_at: task.created_at,<br>            updated_at: new Date(),<br>          },<br>        },<br>        { upsert: true } // Insert if not exists<br>      );<br>    }<br>  }<br><br>  // Process deleted tasks<br>  if (changes.deleted) {<br>    for (const id of changes.deleted) {<br>      await Task.deleteOne({ _id: id });<br>    }<br>  }<br><br>  res.status(200).send(&#39;Changes synchronized successfully&#39;);<br>});<br><br>// Start Server<br>app.listen(3000, () =&gt; console.log(&#39;Server running on port 3000&#39;));</pre><p>Call this function during app startup or on a specific user action:</p><pre>import { database } from &#39;./database&#39;;<br>import { syncDatabase } from &#39;./sync&#39;;<br><br>useEffect(() =&gt; {<br>  syncDatabase(database);<br>}, []);</pre><h4>Test the Application</h4><ul><li>Run the backend server: node server.js</li><li>Start the React Native app: npx react-native run-android or npx react-native run-ios.</li><li>Create, update, and delete tasks offline, then reconnect to the internet to see the synchronization in action.</li></ul><h3>Conclusion</h3><p>Implementing an offline-first architecture with WatermelonDB and MongoDB provides a robust solution for applications requiring high performance and seamless offline functionality. By combining WatermelonDB’s local database capabilities with MongoDB’s powerful backend, you can build apps that offer a reliable user experience, even in challenging network conditions.</p><h3>Find This Helpful?</h3><blockquote>If you found this article helpful, please take a moment to read some of my previous articles. Your support and claps encourage me to create more insightful content like this. Thank you for reading!<br>GitHub Repo : <a href="https://github.com/vineetkrdixit/offlineSync">https://github.com/vineetkrdixit/offlineSync</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7efee1a09bb0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Product Flavors on React Native to Setup multiple build variants]]></title>
            <link>https://medium.com/@vineetdixit.vns/product-flavors-on-react-native-to-setup-multiple-build-variants-a7a90ef183f4?source=rss-a5e44f94615d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a7a90ef183f4</guid>
            <category><![CDATA[build-variants]]></category>
            <category><![CDATA[variant]]></category>
            <category><![CDATA[flavour]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[react-native-config]]></category>
            <dc:creator><![CDATA[Vineetdixit Vns]]></dc:creator>
            <pubDate>Sat, 21 Sep 2024 18:42:48 GMT</pubDate>
            <atom:updated>2024-09-21T18:42:48.766Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5FzzowqRw2J539KKmQ-YyA.jpeg" /></figure><p>Hello everyone! Hope you’re all doing great. Happy to share yet another development experience, which would be useful for fellow react native engineers who wants to set up different flavours for a react native app</p><p><strong>Android Part:-</strong></p><p>In mobile applications, we have something called “mode” and “flavour” — just the categorisation of the apps. They have their variants as follows:-</p><p><strong>Mode:-</strong></p><ol><li>debug mode : the one that requires <a href="https://facebook.github.io/metro/">metro bundler</a> to run along (apps in this mode can’t work stand alone when detached from metro). Typically released in APK format.</li></ol><p>2. release mode : the one that can run independently without the suppport of metro bundler. Typically released in APK format.</p><p><strong>Flavour:-</strong></p><p>It depends on our needs. Typically production grade apps would have three flavours:-</p><p>1. development (Used by dev’s during the development phase)</p><p>2. staging (Used by QA team to do all rounds of testing just before releasing out to LIVE)</p><p>3. production (the one that goes LIVE on Google Play or App Store)</p><p><strong>Step 1: Install </strong><a href="https://www.npmjs.com/package/react-native-config"><strong>react-native-config</strong></a></p><pre>yarn add react-native-config</pre><p><strong>Step 2: Update root &gt; android &gt; app &gt; build.gradle</strong></p><pre><br>project.ext.envConfigFiles = [<br>   productiondebug: &quot;.env.production&quot;,<br>   productionrelease: &quot;.env.production&quot;,<br>   developmentrelease: &quot;.env.development&quot;,<br>   developmentdebug: &quot;.env.development&quot;,<br>   stagingrelease: &quot;.env.staging&quot;,<br>   stagingdebug: &quot;.env.staging&quot;<br>]<br>apply from: project(&#39;:react-native-config&#39;).projectDir.getPath() + &quot;/dotenv.gradle&quot;<br><br>import com.android.build.OutputFile<br><br><br>android {<br>    ndkVersion rootProject.ext.ndkVersion<br>    buildToolsVersion rootProject.ext.buildToolsVersion<br>    compileSdk rootProject.ext.compileSdkVersion<br><br>    namespace &quot;com.reanimated&quot;<br>    defaultConfig {<br>        applicationId &quot;com.reanimated&quot;<br>        minSdkVersion rootProject.ext.minSdkVersion<br>        targetSdkVersion rootProject.ext.targetSdkVersion<br>        versionCode 1<br>        versionName &quot;1.0&quot;<br>    }<br>    signingConfigs {<br>        debug {<br>            storeFile file(&#39;debug.keystore&#39;)<br>            storePassword &#39;android&#39;<br>            keyAlias &#39;androiddebugkey&#39;<br>            keyPassword &#39;android&#39;<br>        }<br>    }<br><br> flavorDimensions &quot;default&quot;<br>   productFlavors {<br>        production {<br>            applicationIdSuffix &quot;reanimated.production&quot;<br>            resValue &quot;string&quot;, &quot;build_config_package&quot;, &quot;com.reanimated&quot;<br>        }<br>        staging {<br>            applicationIdSuffix &quot;reanimated.staging&quot;<br>            resValue &quot;string&quot;, &quot;build_config_package&quot;, &quot;com.reanimated&quot;<br>        }<br>        development {<br>            applicationIdSuffix &quot;reanimated.development&quot;<br>            resValue &quot;string&quot;, &quot;build_config_package&quot;, &quot;com.reanimated&quot;<br>        }<br>    }<br><br>    buildTypes {<br>        debug {<br>            signingConfig signingConfigs.debug<br>            matchingFallbacks = [&#39;debug&#39;, &#39;release&#39;]<br>        }<br>        release {<br>            // Caution! In production, you need to generate your own keystore file.<br>            // see https://reactnative.dev/docs/signed-apk-android.<br>            signingConfig signingConfigs.debug<br>            matchingFallbacks = [&#39;debug&#39;, &#39;release&#39;]<br>            minifyEnabled enableProguardInReleaseBuilds<br>            proguardFiles getDefaultProguardFile(&quot;proguard-android.txt&quot;), &quot;proguard-rules.pro&quot;<br>        }<br>    }<br>}<br></pre><p>project.ext.envConfigFiles = […] instructs the android system that it has different files for different configuration. In this case, we have development, production and staging. The builds are associated with the corresponding configuration for flavours.</p><pre>apply from: project(&#39;:react-native-config&#39;).projectDir.getPath() + &quot;/dotenv.gradle&quot;</pre><p>line of code tells android system to fetch the path for the project and append .env files to the gradle.</p><p><strong>Step 3: Create .env files for each configuration</strong></p><p>— At the root level of the project, create four files:</p><p><strong>.env</strong></p><pre>ENV=root</pre><p><strong>.env.development</strong></p><pre>ENV=development<br>URL=Your Development URl</pre><p><strong>.env.staging</strong></p><pre>ENV=staging<br>URL=Your Staging URl</pre><p><strong>.env.production</strong></p><pre>ENV=production<br>URL=Your Production URl</pre><p>your folder structure will look like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/172/1*wt3ytHQ7dTCg_naefk9KEw.png" /></figure><p><strong>Step 4: Update scripts in package.json</strong></p><pre>    &quot;androidProductionReleaseBundle&quot;: &quot;yarn cache clean &amp;&amp; cd android &amp;&amp; ./gradlew bundleProductionRelease&quot;,<br>    &quot;androidDevelopmentDebugAPK&quot;: &quot;yarn cache clean &amp;&amp; cd android &amp;&amp; ./gradlew assembleDevelopmentDebug&quot;,<br>    &quot;androidDevelopmentReleaseAPK&quot;: &quot;yarn cache clean &amp;&amp; cd android &amp;&amp; ./gradlew assembleDevelopmentRelease&quot;,<br>    &quot;androidProductionDebugAPK&quot;: &quot;yarn cache clean &amp;&amp; cd android &amp;&amp; ./gradlew assembleProductionDebug&quot;,<br>    &quot;androidProductionReleaseAPK&quot;: &quot;yarn cache clean &amp;&amp; cd android &amp;&amp; ./gradlew assembleProductionRelease&quot;,<br>    &quot;androidStagingDebugAPK&quot;: &quot;yarn cache clean &amp;&amp; cd android &amp;&amp; ./gradlew assembleStagingDebug&quot;,<br>    &quot;androidStagingReleaseAPK&quot;: &quot;yarn cache clean &amp;&amp; cd android &amp;&amp; ./gradlew assembleStagingRelease&quot;,</pre><p>These set of commands quickly help us to run the app in particular flavour</p><p><strong>Step 5: In react native app, retrieve it like this:-</strong></p><pre>import Config from &#39;react-native-config&#39;;<br><br>console.log(Config.URL) // prints URL from whichever flavour you run the app</pre><p><strong>Step 6: Create folders inside android &gt; app &gt; src folder</strong></p><ul><li>Copy paste “main” folder thrice, and rename them as the same name we provided in build.gradle : development, staging, production</li><li>Delete “java” folder inside all those 3 folders</li><li>Inside each of these 3 folders, &gt; res &gt; values &gt; strings.xml — update the app name with whatever required like this : “My Dev App”, “My Staging App”, …</li><li>Delete AndroidManifest.xml files inside “development” and “production” folders.</li><li>Don’t disturb these folders : debug, release, main</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/185/1*zWeuD9ZaEjgGdH-MQrbeWw.png" /></figure><p><strong>Step 7: Get the icon set for all sizes from websites like </strong><a href="https://www.appicon.co/">https://www.appicon.co/</a></p><ul><li>You will get a zip file</li><li>Unzip it and you will find icons for all sizes like this.</li><li>Go inside android folder</li><li>Now copy paste these folders onto the three folders: development, staging, production — res folder. Replace the existing folders of same names.</li><li>You can create rounded icons too from the same website and thus the folders could contain images : “ic_launcher.png” and “ic_launcher_rounded.png” under each folder.</li></ul><p><strong>Step 8 : Issue the appropriate command to run the app in debug mode or release an APK from required flavour</strong></p><pre>yarn androidDevelopmentDebugAPK // run app in dev flavour, debug mode<br>yarn androidDevelopmentReleaseAPK // Generate dev APK<br>yarn androidProductionDebugAPK // run app in prod flavour, debug mode <br>yarn androidProductionReleaseAPK // Generate prod APK<br>yarn androidStagingDebugAPK // run app in staging flavour, debug mode<br>yarn androidStagingReleaseAPK // Generate staging APK<br>yarn androidProductionReleaseBundle // generate bundle of prod flavour</pre><p>Woohoo…! We’ve completed the flavours set up and icon set along with the quick and handy commands to run to generate APKs or to run app on the required flavour.</p><h3>Repositoriy</h3><p><a href="https://github.com/vineetkrdixit/reanimated.git">https://github.com/vineetkrdixit/reanimated.git</a></p><p>Thank you for reading this article! Don’t forget to clap only if you think I deserve it👏 and buy me a coffee.</p><p>If you have any queries related to ReactNative, I’m always happy to help you.</p><p>Happy Learning🚀 Happy Coding💻.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a7a90ef183f4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating Husky with a React Native Project for ESLint, Prettier, and TypeScript and Remove…]]></title>
            <link>https://medium.com/@vineetdixit.vns/integrating-husky-with-a-react-native-project-for-eslint-prettier-and-typescript-and-remove-da27f6f0ee7f?source=rss-a5e44f94615d------2</link>
            <guid isPermaLink="false">https://medium.com/p/da27f6f0ee7f</guid>
            <category><![CDATA[code-format]]></category>
            <category><![CDATA[eslint]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[prettier]]></category>
            <category><![CDATA[husky]]></category>
            <dc:creator><![CDATA[Vineetdixit Vns]]></dc:creator>
            <pubDate>Sat, 07 Sep 2024 21:23:52 GMT</pubDate>
            <atom:updated>2024-09-07T21:23:52.798Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Integrating Husky with a React Native Project for ESLint, Prettier, and TypeScript" src="https://cdn-images-1.medium.com/max/960/1*OJ4WWIXifD6wzOhnw6p49Q.png" /><figcaption>Integrating Husky with a React Native Project for ESLint, Prettier, and TypeScript</figcaption></figure><h3>Integrating Husky with a React Native Project for ESLint, Prettier, and TypeScript and Remove Console</h3><p>In modern development workflows, maintaining code quality and consistency is crucial. Tools like ESLint and Prettier help automate code style enforcement and formatting. Husky can further enhance this by automating pre-commit and pre-push hooks to ensure code quality checks are enforced before code changes are committed. This guide will walk you through integrating Husky with a React Native project that uses ESLint, Prettier, and TypeScript.</p><h3>Prerequisites</h3><p>Before you start, ensure you have the following installed:</p><ul><li>Node.js and npm (or Yarn)</li><li>React Native CLI</li><li>A React Native project set up with TypeScript, ESLint, and Prettier</li></ul><h3>Step 1: Set Up ESLint and Prettier</h3><h3>1.1 Install ESLint and Prettier</h3><p>First, you need to install ESLint, Prettier, and their necessary plugins:</p><pre>npm install --save-dev eslint prettier eslint-plugin-react eslint-plugin-react-native eslint-plugin-import @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-config-prettier eslint-plugin-prettier</pre><h3>1.2 Configure ESLint</h3><p>Create an .eslintrc.js file in your project root with the following configuration:</p><pre>module.exports = {<br> root: true,<br> extends: [<br>  &#39;eslint:recommended&#39;,<br>  &#39;plugin:react/recommended&#39;,<br>  &#39;plugin:@typescript-eslint/recommended&#39;,<br> ],<br> parser: &#39;@typescript-eslint/parser&#39;,<br> plugins: [&#39;@typescript-eslint&#39;, &#39;react&#39;],<br> env: {<br>  browser: true,<br>  node: true,<br> },<br> rules: {<br>  &#39;react/react-in-jsx-scope&#39;: &#39;off&#39;,<br>  &#39;no-unused-vars&#39;: &#39;warn&#39;,<br>  &#39;react/prop-types&#39;: &#39;off&#39;,<br>  &#39;@typescript-eslint/no-explicit-any&#39;: &#39;error&#39;, // Disallow usage of any<br>  &#39;@typescript-eslint/explicit-module-boundary-types&#39;: &#39;error&#39;, // Ensure types are explicitly declared<br> },<br>};</pre><h3>1.3 Configure Prettier</h3><p>Create a .prettierrc file in your project root:</p><pre>module.exports = {<br> arrowParens: &#39;always&#39;,<br> bracketSpacing: true,<br> jsxBracketSameLine: true,<br> jsxSingleQuote: true,<br> singleQuote: true,<br> semi: true,<br> printWidth: 100,<br> useTabs: true,<br> tabWidth: 4,<br> arrowParens: &#39;always&#39;,<br> endOfLine: &#39;lf&#39;,<br> trailingComma: &#39;all&#39;,<br>};</pre><h3>1.4 Add Custom Script to Remove console Statements</h3><p>Create a file <strong>remove_console.js</strong> file in root directory of your App and add following code snippet</p><pre>/* eslint-disable @typescript-eslint/no-var-requires */<br>const fs = require(&#39;fs&#39;);<br><br>const files = process.argv.slice(2);<br><br>files.forEach((file) =&gt; {<br> const content = fs.readFileSync(file, &#39;utf8&#39;);<br> const updatedContent = content.replace(/console\.log\(.*?\);?/g, &#39;&#39;);<br> fs.writeFileSync(file, updatedContent, &#39;utf8&#39;);<br>});</pre><h3>Step 2: Install and Configure Husky</h3><h3>2.1 Install Husky</h3><p>Install Husky and lint-staged:</p><pre>npm install --save-dev husky lint-staged</pre><h3>2.2 Set Up Husky</h3><p>Initialize Husky:</p><pre>npx husky init</pre><p>Add Husky hooks to your package.json:<br>you can add this code bloack after “devDependencies”</p><pre>  &quot;lint-staged&quot;: {<br>    &quot;*.{js,jsx,ts,tsx}&quot;: [<br>      &quot;node remove_console.js&quot;,<br>      &quot;prettier --write&quot;,<br>      &quot;eslint --fix&quot;<br>    ]<br>  },</pre><h3>2.3 Configure Husky Hooks</h3><p>Add a pre-commit hook to run lint-staged:<br>pre-commit should be in root directory of .husky folder</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*YMMK7rLqyHp1a2ger9bwVw.png" /></figure><h3>Step 3: Verify the Setup</h3><h3>3. Make a Commit</h3><p>Make a code change and try to commit it. Husky should trigger lint-staged, which will run ESLint and Prettier automatically before the commit is finalized.</p><h3>Conclusion</h3><p>Integrating Husky with ESLint and Prettier in a React Native project helps automate code quality checks and enforce consistent code styles. This setup ensures that code quality is maintained across your development team and minimizes issues that can arise from inconsistent code formatting and linting errors. With Husky in place, you can focus more on writing code and less on managing code quality issues.</p><p>By following these steps, you’ll have a robust workflow that maintains high code quality and consistency in your React Native project.</p><h3>Repositoriy</h3><p><a href="https://github.com/vineetkrdixit/reanimated.git">https://github.com/vineetkrdixit/reanimated.git</a></p><p>Thank you for reading this article! Don’t forget to clap only if you think I deserve it👏 and buy me a coffee.</p><p>If you have any queries related to ReactNative, I’m always happy to help you.</p><p>Happy Learning🚀 Happy Coding💻.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da27f6f0ee7f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating React Native with Fastlane and CircleCI for Deploying APKs to Firebase App Distribution]]></title>
            <link>https://medium.com/@vineetdixit.vns/integrating-react-native-with-fastlane-and-circleci-for-deploying-apks-to-firebase-app-distribution-5ee2ed0876d1?source=rss-a5e44f94615d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ee2ed0876d1</guid>
            <category><![CDATA[circleci]]></category>
            <category><![CDATA[firebase-app-distribution]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[fastlane]]></category>
            <dc:creator><![CDATA[Vineetdixit Vns]]></dc:creator>
            <pubDate>Mon, 29 Jul 2024 18:15:15 GMT</pubDate>
            <atom:updated>2024-08-24T08:14:57.268Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*60-56t9BD7oCOuPN3jXdhw.png" /></figure><p>Deploying mobile applications efficiently is crucial for maintaining a rapid development cycle and ensuring high-quality releases. For React Native applications, integrating continuous deployment tools like Fastlane and CircleCI with Firebase App Distribution can streamline the release process, reduce manual intervention, and improve overall productivity. This article will guide you through setting up this integration.</p><h4>Prerequisites</h4><p>Before we begin, ensure you have the following:</p><ol><li>A React Native project.</li><li>A Firebase project with App Distribution set up.</li><li>A CircleCI account.</li><li>Fastlane installed on your development machine.</li></ol><h4>Step 1: Setting Up Fastlane</h4><p>Fastlane is a tool that automates the deployment of mobile applications. To integrate Fastlane with your React Native project, follow these steps:</p><ol><li><strong>Install Fastlane:<br></strong> Open your terminal and navigate to your React Native project directory. Run the following command to install Fastlane:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*yzTatl4DgAo8kmH1XUeb8w.png" /></figure><p>2. <strong>Initialize Fastlane:</strong> <br> Initialize Fastlane in your project by running:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*kGYtsIyeMNlKEHyt4kaL_Q.png" /></figure><p>3. <strong>Configure Fastlane:</strong> Open the generated Fastfile located in the android/fastlane directory. Replace the content with the following configuration to build your APK and upload it to Firebase App Distribution</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*wco_vLC9Js30KDsLRe3bXQ.png" /></figure><p>Replace YOUR_FIREBASE_APP_ID with your Firebase App ID, and adjust the testers and release_notes as needed.</p><p>4.<strong>Add Firebase App Distribution Plugin:<br></strong> Add the Firebase App Distribution plugin to your Gemfile:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*8-ByqWu3sNkJ3Pst80Fh3w.png" /></figure><p>then run:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*1P0FMO2kCydLdM9eVtiSNg.png" /></figure><h4>Step 2: Setting Up CircleCI</h4><p>CircleCI is a continuous integration and delivery platform that automates the build, test, and deployment process. To integrate CircleCI with your project, follow these steps:</p><ol><li><strong>Create a CircleCI Configuration File:</strong> In the root of your React Native project, create a folder named .circleci and add a file named config.yml with the following content:</li></ol><pre>version: 2.1<br><br>executors:<br>    android:<br>        docker:<br>            - image: reactnativecommunity/react-native-android:latest<br>jobs:<br>    build:<br>        executor: android<br>        environment:<br>            LC_ALL: &#39;en_US.UTF-8&#39;<br>            LANG: &#39;en_US.UTF-8&#39;<br>            GRADLE_OPTS: &#39;-Xmx2014m -Dorg.gradle.daemon=false -Dorg.gradle.jvmargs=&quot;-XX:+UnlockExperimentalVMOptions -XX:+HeapDumpOnOutOfMemoryError&quot;&#39;<br>        steps:<br>            - checkout<br>            # Ensure the correct directory<br>            - run:<br>                  name: Ensure correct directory<br>                  command: pwd &amp;&amp; ls -la<br>            # Cache Yarn dependencies<br>            - run:<br>                  name: Download and install dependencies<br>                  command: |<br>                      sudo apt-get update<br>                      sudo apt-get install -y curl<br>                      curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash<br>                      export NVM_DIR=&quot;$HOME/.nvm&quot;<br>                      [ -s &quot;$NVM_DIR/nvm.sh&quot; ] &amp;&amp; . &quot;$NVM_DIR/nvm.sh&quot;<br>                      nvm install 20.11.0<br>                      nvm use 20.11.0<br>                      npm install -g yarn<br>                      yarn install<br>            - save_cache:<br>                  paths:<br>                      - ~/.cache/yarn<br>                  key: v1-yarn-cache-{{ checksum &quot;yarn.lock&quot; }}<br>            # Cache Gradle dependencies<br>            - restore_cache:<br>                  keys:<br>                      - v1-gradle-cache-{{ checksum &quot;android/build.gradle&quot; }}<br>                      - v1-gradle-cache-<br>            - run:<br>                  name: List Android directory before secretKey contents<br>                  command: ls -la<br>                  working_directory: android<br>            - run:<br>                  name: Decrypting Service_account_key<br>                  command: |<br>                      base64 -di fbt &gt; fbt.json<br>                  working_directory: android<br>            - run:<br>                  name: List Android directory after secretKey contents<br>                  command: ls -la<br>                  working_directory: android<br>            - run:<br>                  name: Set permissions for Gradle<br>                  command: chmod +x ./android/gradlew<br>            - run:<br>                  name: Install Fastlane<br>                  command: bundle install<br>                  working_directory: android<br>            - run:<br>                  name: Update Fastlane<br>                  command: bundle update fastlane<br>                  working_directory: android<br>            - run:<br>                  name: Clean and Build APK<br>                  command: |<br>                      cd android<br>                      export NVM_DIR=&quot;$HOME/.nvm&quot;<br>                      [ -s &quot;$NVM_DIR/nvm.sh&quot; ] &amp;&amp; . &quot;$NVM_DIR/nvm.sh&quot;<br>                      nvm use 20.11.0<br>                      chmod +x gradlew<br>                      ./gradlew clean<br>                      ./gradlew assembleRelease<br>            - save_cache:<br>                  paths:<br>                      - ~/.gradle<br>                  key: v1-gradle-cache-{{ checksum &quot;android/build.gradle&quot; }}<br>            - run:<br>                  name: Add Firebase App Distribution Plugin<br>                  command: bundle exec fastlane add_plugin firebase_app_distribution<br>                  working_directory: android<br>            - run:<br>                  name: Deploy to Firebase<br>                  command: bundle exec fastlane distribute<br>                  working_directory: android<br>            # - store_artifacts:<br>            #       path: android/app/build/outputs/apk/release/app-release.apk<br>            #       destination: app-release.apk<br>workflows:<br>    version: 2<br>    build:<br>        jobs:<br>            - build</pre><p><strong>2.Set Up Environment Variables:</strong> In the CircleCI dashboard, navigate to your project settings and add the following environment variables:</p><ul><li>FIREBASE_TOKEN: This token is used by Fastlane to authenticate with Firebase. Generate a token by running firebase login:ci and follow the instructions.</li></ul><h4>Step 3: Running the Pipeline</h4><p>Commit your changes and push them to your repository. CircleCI will automatically start the build process, running the steps defined in your config.yml file. Once the build is successful, Fastlane will deploy the APK to Firebase App Distribution.</p><h4>Reference</h4><p><a href="https://github.com/vineetkrdixit/ExpoRouter">https://github.com/vineetkrdixit/ExpoRouter</a></p><h4>Conclusion</h4><p>Integrating React Native with Fastlane and CircleCI for deploying APKs to Firebase App Distribution automates and simplifies the deployment process. This setup ensures that your application is consistently and reliably built, tested, and distributed, allowing you to focus on developing new features and improving the user experience. With continuous integration and deployment in place, you can deliver high-quality updates to your users more efficiently.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ee2ed0876d1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Expo Router V3 Nested Drawer with Tab and Authentication]]></title>
            <link>https://medium.com/@vineetdixit.vns/expo-router-v3-nested-drawer-with-tab-and-authentication-42da42f44c88?source=rss-a5e44f94615d------2</link>
            <guid isPermaLink="false">https://medium.com/p/42da42f44c88</guid>
            <category><![CDATA[expo]]></category>
            <category><![CDATA[drawer]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[expo-router]]></category>
            <dc:creator><![CDATA[Vineetdixit Vns]]></dc:creator>
            <pubDate>Sat, 29 Jun 2024 15:08:51 GMT</pubDate>
            <atom:updated>2024-06-29T19:15:44.036Z</atom:updated>
            <content:encoded><![CDATA[<p>Since this is my first article about how to create a <strong>Expo Router Nested Drawer with Tab and Authentication</strong> I thought I’d create an updated version. This version uses Expo Router v3 and Expo SDK 51.</p><p><a href="https://vimeo.com/971578346">https://vimeo.com/971578346</a></p><p>Step-by-Step Guide for Setting Up Authentication</p><ol><li><strong>Creating the Authentication Folder</strong>:</li></ol><ul><li>Navigate to your app directory.</li><li>Create a new folder named auth inside the app directory.</li></ul><p><strong>2. Setting Up the Layout for Authentication Screens</strong>:</p><ul><li><strong>Setting Up the Layout for Authentication Screens</strong>:</li><li>Inside the newly created auth folder, create a file named _layout.js.</li><li>In app/(auth)/_layout.js, set up a stack navigator to manage all your authentication screens.</li></ul><p><strong>3.Refer to the Diagram Below</strong>:</p><ul><li>Please refer to the image below for a visual representation of the folder structure and layout setup.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*mlFY_aGQojC0M1jPngoFIA.png" /></figure><p>Now create a (drawer) folder with a file _layout<br>it will be like app/(drawer)/_layout.tsx, which will have all the custom drawer content</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*LZfkeJLIAdEDLL-2jocFEg.png" /></figure><p>Now create a (tab) folder with a file _layout<br>it will be like app/(drawer)/(tab)/_layout.tsx, which will have all the custom drawer content</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*UBcOfm2x1kw-k-SJpf-Peg.png" /></figure><p>After completing the all steps you will finally get the Drawer and tab nested inside <br>Here is the video of the Drawer with Tab and authentication</p><p><a href="https://github.com/vineetkrdixit/ExpoRouter">Here is the repository for the full code</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42da42f44c88" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>