<?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 Bharat Bhushan on Medium]]></title>
        <description><![CDATA[Stories by Bharat Bhushan on Medium]]></description>
        <link>https://medium.com/@bhushanbharat?source=rss-57260fd44eca------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*smZC4DhZ7rrzWRPsYjtF9w.jpeg</url>
            <title>Stories by Bharat Bhushan on Medium</title>
            <link>https://medium.com/@bhushanbharat?source=rss-57260fd44eca------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 19:50:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bhushanbharat/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[Issues faced when trying to enable new architecture in react native]]></title>
            <link>https://bhushanbharat.medium.com/issues-faced-when-trying-to-enable-new-architecture-in-react-native-96cae35d27ac?source=rss-57260fd44eca------2</link>
            <guid isPermaLink="false">https://medium.com/p/96cae35d27ac</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[react-native-performance]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[turbo-module]]></category>
            <category><![CDATA[new-architecture]]></category>
            <dc:creator><![CDATA[Bharat Bhushan]]></dc:creator>
            <pubDate>Wed, 18 Jan 2023 12:48:31 GMT</pubDate>
            <atom:updated>2023-01-18T12:48:31.759Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Problem 1</strong>: <br>Couldn’t determine the CLI location. Please set project.ext.react.cliPath to the path of the react-native cli.js</p><blockquote><strong><em>Solution</em></strong>:<br> add this to your project gradle:<br>project.ext.react = [ cliPath: [“node”, “-e”, “console.log(require(‘react-native/cli’).bin);”].execute([], projectDir).text.trim()</blockquote><p><strong>Problem 2:<br></strong>Project with path ‘:ReactAndroid’ could not be found in project ‘</p><blockquote><strong>Solution:</strong></blockquote><blockquote>if (settings.hasProperty(&quot;newArchEnabled&quot;) &amp;&amp; settings.newArchEnabled == &quot;true&quot;) {<br>//conditional creating problem<br> }<br>//these should be kept independently<br>include(&quot;:ReactAndroid&quot;)<br>project(&quot;:ReactAndroid&quot;).projectDir = file(&#39;../../../node_modules/react-native/ReactAndroid&#39;)<br>include(&quot;:ReactAndroid:hermes-engine&quot;)<br>project(&quot;:ReactAndroid:hermes-engine&quot;).projectDir = file(&#39;../../../node_modules/react-native/ReactAndroid/hermes-engine&#39;)</blockquote><p><strong>Problem 3:<br></strong>Could not get unknown property ‘ExtractJniAndHeadersTask’ for project ‘:ReactAndroid’ of type org.gradle.api.Project.</p><blockquote><strong>Solution:<br></strong>Removed the react-native-gradle-plugin library</blockquote><p><strong>Problem 4:</strong></p><p>/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt: (137, 11): This declaration is experimental and its usage must be marked with ‘<a href="http://twitter.com/kotlin">@kotlin</a>.ExperimentalStdlibApi’ or ‘<a href="http://twitter.com/OptIn">@OptIn</a>(kotlin.ExperimentalStdlibApi::class)’</p><blockquote><strong>Solution:<br></strong>Add <a href="http://twitter.com/kotlin">@kotlin</a>.ExperimentalStdlibApi notation in the BundleHermesCTask.kt file-&gt; although this needs to be done within the node_modules as of now</blockquote><p><strong>Problem 5: <br></strong>Error resolving plugin [id: ‘org.jetbrains.kotlin.android’, version: ‘1.6.10’]<br>&gt; The request for this plugin could not be satisfied because the plugin is already on the classpath with an unknown version, so compatibility cannot be checked.</p><blockquote><strong>Solution</strong>:<br>Removing the line id(“org.jetbrains.kotlin.android”) version “1.6.10” from n/node_modules/react-native/ReactAndroid/build.gradle</blockquote><p><strong>Problem 6:<br></strong>[CXX1400] Gradle project ndkBuild.path is /home/fad03mhr3/Desktop/Apps/new_arch_13jan/packages/react-native/android/_99acres/src/main/jni/Android.mk but that file doesn’t exist</p><p><strong>Problem 7:<br></strong>[CXX1405] error when building with ndkBuild using /home/fad03mhr3/Desktop/Apps/new_arch_13jan/packages/react-native/android/_99acres/src/main/jni/Android.mk: Build command failed.</p><p><strong>Problem 8:<br></strong>Invalid value for “PACKAGE_PATH”: Directory “/home/Desktop/Apps/new_arch_13jan/node_modules/react-native/ReactAndroid/hermes-engine/build/intermediates/prefab_package/debug/prefab” is not readable.</p><p><strong>Problem 9:<br></strong>Failed to notify project evaluation listener.<br> &gt; /homw/Apps/new_arch_13jan/packages/react-native/node_modules/react-native/ReactAndroid/gradle.properties (No such file or directory)<br> &gt; Could not get unknown property ‘configureNdkBuildRelease’ for extension ‘android’ of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96cae35d27ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Under-Rated practices to improve React Native performances]]></title>
            <link>https://bhushanbharat.medium.com/under-rated-practices-to-improve-react-native-performances-9a8c261e1890?source=rss-57260fd44eca------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a8c261e1890</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[react-native-performance]]></category>
            <category><![CDATA[rerender]]></category>
            <dc:creator><![CDATA[Bharat Bhushan]]></dc:creator>
            <pubDate>Mon, 22 Aug 2022 16:30:09 GMT</pubDate>
            <atom:updated>2022-08-22T16:30:09.124Z</atom:updated>
            <content:encoded><![CDATA[<ol><li><strong>Avoid the use of inline functions as props<br></strong>Every re-render of the parent will result in a new reference for the function passed to the child hence updating the prop for the child resulting in unnecessary child re-rendering.</li></ol><pre><strong>// Wrong Practice<br></strong>&lt;SomeChildComponent <br>  onPress={()=&gt; console.log(&#39;passing some random inline function&#39;)}<br>/&gt;<br><strong>// Right Practice<br></strong>function someFunc(){ // your work here within function<br>}<br>&lt;SomeChildComponent <br>  onPress={someFunc}<br>/&gt;</pre><p>2.<strong> Make use of Flatlist instead of map functions for a more extensive set of data</strong></p><pre><strong>// Wrong Practice<br></strong>&lt;ScrollView&gt;<br>  &lt;View style={styles.centerRow}&gt;<br>    {someLargeChunkOfData.map((item, index) =&gt; {<br>    return &lt;SomeBulkyUiChunk {...item} /&gt;;<br>    })}<br>  &lt;/View&gt;<br>&lt;/ScrollView&gt;;</pre><pre><strong>// Right Practice<br></strong>&lt;Flatlist <br>data={someLargeChunkOfData}<br>renderItem={renderBulkyUI}<br>/&gt;<br>function renderBulkyUI({item,index}){<br>return &lt;SomeBulkyUiChunk {...item} /&gt;<br>}</pre><p>3.<strong> Avoid the use of inline objects as props</strong></p><p>Passing objects directly in props results in the creation of a new instance of the object on every re-render instead of using the same reference.</p><pre><strong>// Wrong Practice<br></strong>&lt;SomeChildComponent randomProps={{data:&quot;some random chunk&quot;}}/&gt;</pre><pre><strong>// Right Practice<br></strong>const data=&quot;some random chunk defined outside scope&quot;<br>&lt;SomeChildComponent randomProps={data}/&gt;</pre><p>4.<strong> Make use of stylesheet objects instead of inline stylings<br></strong>A new render creates a new instance of the inline styling object but styles created via StyleSheet are passed as a reference.</p><pre><strong>// Wrong Practice<br></strong>&lt;SomeChildComponent style={{height:112,color:&quot;red&quot;}}/&gt;</pre><pre><strong>// Right Practice<br></strong>&lt;SomeChildComponent style={styles.compStyle}/&gt;<br>const styles = StyleSheet.create({<br>   compStyle: {<br>                height:112,<br>                color:&quot;red&quot;<br>              }});</pre><p>5. <strong>Use Memo/use callback functions to avoid unnecessary renders</strong></p><p>There are high chances that some basic loopholes may also cause blunders of re-renders. To prevent such renders best way is to master react…..haha…shortcut to save you is using memo and callback hooks.</p><p>useCallback is used when you are passing callbacks as props to the child component, To avoid any unnecessary re-render we wrap our callback with the hook which will only change the callback when some dependency is changed.</p><p>useMemo is similar to useCallback, the only difference is that it returns memoized value being returned by the function being passed.</p><pre><strong>// Wrong Practice<br></strong>&lt;SomeChildComponent childFunc={()=&gt;{//do some boring stuff}}/&gt;</pre><pre><strong>// Right Practice<br></strong>&lt;SomeChildComponent <br>childFunc={childFunc} /&gt;</pre><pre>const childFunc=useCallback(()=&gt;{<br>//do the same boring stuff here<br>})</pre><p>6. <strong>Avoid using arrow functions for UI components as it created a new reference on every render</strong></p><p>Strange to the fact that the most useful invention of ES6 is a bottleneck for React. The arrow functions when passed to the child will create a new reference on each render hence is an awful practice</p><pre><strong>// Wrong Practice<br></strong>&lt;SomeChildComponent childFunc={()=&gt;{//do some boring stuff}}/&gt;</pre><pre><strong>// Right Practice<br></strong>&lt;SomeChildComponent <br>childFunc={onePossibleWayFunc} <br>anotherChildFunc={anotherPossibleWayFunc}/&gt;</pre><pre>function onePossibleWayFunc(){<br>//do the same boring stuff here<br>}<br>const anotherPossibleWayFunc=useCallBack(()=&gt;{<br>//obsessed with arrow functions use useCallback and <br>//do the same boring stuff here<br>})</pre><p>7. <strong>Remove the consoles before publishing the apps.</strong></p><p>console.log is a synchronous call and runs on the javascript thread resulting in a huge bottleneck(react-native docs says so..)</p><pre><strong>// Best Practices<br>Kids</strong>- make use of <strong>babel-plugin-transform-remove-console<br>Legends-</strong>  if (__DEV__) {<br>    // eslint-disable-next-line no-console<br>    console.log(message, ...optionalParams)<br>  }<strong><br>Ultra Legends- </strong>if (__DEV__) {<br>   Alert.alert(message)<br>  }<br><strong>Ultra Legend Pro Max- </strong>Don&#39;t use consoles </pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a8c261e1890" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to implement Interfaces in JavaScript ?]]></title>
            <link>https://bhushanbharat.medium.com/how-to-implement-interfaces-in-javascript-24826094e805?source=rss-57260fd44eca------2</link>
            <guid isPermaLink="false">https://medium.com/p/24826094e805</guid>
            <category><![CDATA[class]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[interfaces]]></category>
            <category><![CDATA[js]]></category>
            <dc:creator><![CDATA[Bharat Bhushan]]></dc:creator>
            <pubDate>Tue, 04 Jan 2022 04:34:38 GMT</pubDate>
            <atom:updated>2022-08-22T16:26:36.084Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to implement Interfaces in JavaScript?</h3><p>Interfaces are the most commonly used tool when it comes to Object Oriented Programming. We all are familiar with the term as it provides a way of specifying what methods an object could have. In short, we are bounding the similarities together and then partially enforcing strict typing.</p><p>JavaScript has no built-in interface support. We may here try to create our own interface class and make it hold information about what methods should be implemented and what arguments it should hold.</p><p>Let’s begin by creating an Interface.js class.</p><pre>class Interface{<br>  constructor(name,methods){<br>  }<br>}</pre><p>We will proceed with a pattern that the interface class and would expect a name and an array of methods expected. <br> example: var Student= new Interface(‘Registration’,[‘add’,’remove’,’getStudent’]);</p><p>For this, our interface constructor should be defined as something like</p><pre>constructor(name, methods) {<br>  if (arguments.length !== 2) {<br>    throw new Error(&#39;Interface constructor called with &#39; +   <br>    arguments.length +&#39; arguments, but expected exactly two    <br>    arguments.&#39;);<br>  }<br>  this.name = name;<br>  this.methods = [];<br>  for (let i = 0; i &lt; methods.length; i++) {<br>    if (typeof methods[i] !== &#39;string&#39;) {<br>      throw new Error(&#39;Interface constructor expects methods name to  <br>      be passed in as a string&#39;);<br>    }<br>    this.methods.push(methods[i]);<br>  }<br>}</pre><p>Our next challenge arises on how to ensure that the class implementing the interface is actually implementing the correct set of methods. For this, we will add a static enforced method to type-check the interface as well as the methods being implemented.</p><pre>static ensureImplementsInterface(object) {<br>  if (arguments.length &lt; 2) {<br>    throw new Error(&#39;Function Interface.ensureImplementsInterface   <br>    called with&#39; + arguments.length + &#39; arguments, but expected <br>    at least two arguments.&#39;);<br>  }<br>  for (let i = 1; i &lt; arguments.length; i++) {<br>    var currentInterface = arguments[i];<br>    if (currentInterface.constructor !== Interface) {<br>      throw new Error(&#39;Function Interface.ensureImplementsInterface<br>      expects two arguments and to be an instances of Interface &#39;);<br>    }<br>    for (let j = 0; j &lt; currentInterface.methods.length; j++) {<br>     var currentMethod = currentInterface.methods[j];<br>      if (!object[currentMethod] ||<br>         typeof object[currentMethod] !== &#39;function&#39;) {<br>         throw new Error(&#39;Object does not implement the &#39; +  <br>         currentInterface.name + &#39; inteface.method &#39; + currentMethod   <br>         + &#39; was not found&#39;)<br>     }<br>   }<br>  }<br>}</pre><p>Using this simple Interface class we can create any interface and type-check the requirements.</p><pre>var InterfaceExample=new Interface(&#39;InterfaceExample&#39;,[&#39;method1&#39;,&#39;method2&#39;,&#39;method3&#39;]);</pre><pre>function tryExample(){<br>  Interface.ensureImplementsInterface(this,InterfaceExample);<br>  this.method1(); // define the usage<br>  this.method2(&quot;dummy arguments&quot;);<br>  this.method3(1,2);<br>  .....<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24826094e805" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Formulate- Architecture to Create Dynamic Forms using JSON]]></title>
            <link>https://bhushanbharat.medium.com/formulate-architecture-to-create-dynamic-forms-using-json-5f10a441e621?source=rss-57260fd44eca------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f10a441e621</guid>
            <category><![CDATA[dynamic-layout]]></category>
            <category><![CDATA[json-to-view]]></category>
            <category><![CDATA[dynamic-form]]></category>
            <category><![CDATA[dynamic-sreen]]></category>
            <category><![CDATA[formulate]]></category>
            <dc:creator><![CDATA[Bharat Bhushan]]></dc:creator>
            <pubDate>Mon, 08 Feb 2021 11:20:53 GMT</pubDate>
            <atom:updated>2021-02-08T11:20:53.518Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we will be sharing how we are handling the form based journey in applications. It started as a thought to dynamically handle the form based journeys along with all the possible functionalities a form may need.</p><p><strong>Why we developed Formulate?</strong></p><p>We work on an application which is concentric towards form based journeys which are dependent on third parties and the count of such journeys is quite large. The major concern we got was :-</p><ol><li>The frequent changes as requested by the third parties.</li><li>Complexity and confusions in managing such similar form components.</li><li>Easy maintenance of JSON’s as compared to code</li></ol><p><strong>What is Formulate?</strong></p><p>To handle this complexity we came up with an idea to create forms dynamically using JSONs that will be maintained at the server layer. The JSON’s will be loaded during runtime and will be rendered by the Formulate Mapper efficiently.This helps us handle vulnerable form updates in no time.</p><p>But the journey was never easy, we started with creating the base layer which included the basic level components that were to be the base for the journey specific components and could accept any kind of theme and handlings explicitly. For Instance we have the text input with a particular animating label feature and standard styling.</p><p>The second layer was the core which was the actual handle to the entire idea of Formulate. The components built over the base layer were self sustained(all the validations and error handling was handled by the component itself).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/191/0*k7-ocBSLcKXCa6R4" /></figure><p>The third layer had to be something which could bind all these components together basis the requirement and here come’s the toughest job to do. We first designed a JSON format such that it could represent a complete journey which was a collection of n numbers of screens which individually was a collection of the m number of core/base/native layer components. Once we freezed the pattern the parser was set in action. Basically the parser was the main exposed layer which expected a JSON as input and in return gave us a full fledged form based journey.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/0*uUojP_OUMvhQP5-u" /></figure><p><strong>Understanding the Screen JSON</strong></p><p>The JSON is an array of states where each state represents a complete screen. Each state object has multiple keys which provide the entire UI creation and corresponding handling. It starts from accepting the basic details like the title, titleStyle, index, array of fields to passing the complex actions(form validating, api calls, sending GA events etc.) to be fired on different triggers (eg. onPress, onFocus etc.). We also have the feasibility to fire actions at the screen level for example we want to fire an API the moment the user lands on the current screen, we can easily do this by passing actionIds and a triggerType.</p><p>The Fields array being passed in the individual state object is nothing but the list of core components arranged sequentially as per the requirement. Along with the type it includes add-on details required by the individual components. We define the action ids and trigger type if any particular component is required to fire some action. The actionIds array maps itself with the screen’s action array mentioned to find its corresponding executable action.</p><p>The actions array contains all the possible set of actions possible on the particular screen irrespective of component level or screen level triggers. The actions are linked using the ids provided which decides the firing parent and the trigger type. We also have the accessibility to decide whether the given action will be fired synchronously or asynchronously with its consecutive action. The parser is capable of handling all sorts of possible actions a form based screen demands (be it validating the entire form, navigating to the next json screen, returning to native journey, making api calls and the list continues).</p><p><strong>Formulate Architecture</strong></p><p>The mapper designed to read this screen JSON was subdivided into smaller parsers to allow easy handling of the journey. As the JSON visualizes three broad divisions of a screen into component handling, actions handling and screen level handling, the mapper is constructed of the <strong>Screen Mapper</strong>, <strong>Action Mapper</strong> and the <strong>Component Mapper</strong>.</p><p>The screen mappers function is to maintain the current screen and handle all possible workings of the screen. For this it lies centrally interacting with the component mapper and the action mapper directly since these two do not connect directly. The component mapper’s role is to create the components from the given fields array and pass the corresponding actions concerned with the field. The component mapper also has the provision to design containers with a set of components or static UI’s. The entire journey maintains a single copy of the instance like a singleton class so that at any point of time data could be easily accessible and altered if required.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QS6ThLrVh-0uGf-K" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f10a441e621" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>