<?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 Hassan Saleh on Medium]]></title>
        <description><![CDATA[Stories by Hassan Saleh on Medium]]></description>
        <link>https://medium.com/@hassansaleh31?source=rss-d795b3929136------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*92kv4tHHcN2mL0sN.jpg</url>
            <title>Stories by Hassan Saleh on Medium</title>
            <link>https://medium.com/@hassansaleh31?source=rss-d795b3929136------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 22:30:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hassansaleh31/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[What I learned after switching from Flutter to React]]></title>
            <link>https://medium.com/outreach-prague/what-i-learned-after-switching-from-flutter-to-react-377117197ef4?source=rss-d795b3929136------2</link>
            <guid isPermaLink="false">https://medium.com/p/377117197ef4</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[career-change]]></category>
            <category><![CDATA[best-practices]]></category>
            <dc:creator><![CDATA[Hassan Saleh]]></dc:creator>
            <pubDate>Thu, 10 Jul 2025 12:40:14 GMT</pubDate>
            <atom:updated>2025-07-10T13:51:20.840Z</atom:updated>
            <content:encoded><![CDATA[<p>Before I joined Outreach as a React Engineer, I was a Flutter Engineer for more than five years, working on building cross platform mobile applications. I have used React before, but it was just for fun and that was before hooks were a thing. I will share with you my first impressions, some challenges I faced, and how I overcame them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pzuZOSPkrNgy2V_C0C95Iw.png" /></figure><h3><strong>First Impressions</strong></h3><p>When I started refreshing my knowledge on React, I noticed how similar it is to Flutter in many ways, widgets and components are remarkably similar in concept and the languages have similar syntax that made the transition even easier.</p><p>Let’s take a quick look at the similarity between Flutter widgets, React components, and code syntax.</p><pre>╔═══════════════════════════════════╦════════════════════════════════╗<br>║              Flutter              ║             React              ║<br>╠═══════════════════════════════════╬════════════════════════════════╣<br>║ Stateless Widget                  ║ Functional Component           ║<br>║ Stateful Widget                   ║ Functional Component + hooks   ║<br>║ Inherited Widget                  ║ Context API                    ║<br>║ names.map(e =&gt; Text(e)).toList()  ║ names.map(e =&gt; (&lt;p&gt; {e} &lt;/p&gt;)) ║<br>╚═══════════════════════════════════╩════════════════════════════════╝</pre><p>If we look at the table above, we can see that there are some similarities between Flutter and React. The 3 most used Flutter widget types have direct alternatives in React. I find React components cleaner and more readable than Flutter widgets especially when comparing them with Stateful widgets.</p><p>Code wise, Dart and typescript also have some similarities, for example array iterators, arrow functions, async operations, etc…</p><p>After discovering these similarities, I thought that the transition would be a piece of cake.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6DL4oWSvEygzkoSG6ImHLQ.png" /></figure><h3>Challenges</h3><p>The first couple of weeks as a React Engineer went well, better than I expected. At that time, I was fixing bugs from the backlog so I could get myself familiar with the code.</p><p>But debugging is one thing and writing a feature from scratch in a codebase you’re not familiar with yet is a completely different thing. After the first couple of weeks, I was assigned to build my first feature. What could go wrong, right?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*v9JlIGKG6K5MS5o91FXRQA.png" /></figure><p>The most challenging part for me personally was state management in React, mostly because during the past five years I got used to a certain way of writing code that is inspired by the clean architecture by Uncle Bob, and it depends on different state management packages to simplify the code and make the app more efficient.</p><p>When it comes to React, most companies avoid relying on third party state management solutions for reasons we will not touch on in this article. So, I had to work with what React has to offer, using components, hooks, and context to build that feature.</p><p>I finally managed to do it, and I submitted a pull request for peer review, but…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*atF9tQXtACyrIf5p9R1p0A.png" /></figure><p>While the feature works as it’s supposed to do, the implementation was not perfect. The team had concerns about the performance of my code, and this is when I started learning how React works under the hood.</p><h3>Bad Practices</h3><p>While I was fixing these performance issues, I learned that there are 3 main bad practices that beginners face when learning React.</p><h4>Global State</h4><p>The most important thing I learned about React is how a component re-renders and what gets re-rendered. For example, if we look at this piece of code below, you can see that we have a state inside App and this state is provided to all children of App using context.</p><pre>function App() {<br>  const state = useState();<br><br>  return (<br>    &lt;AppContext.Provider value={state}&gt;<br>      &lt;SomeHeavyComponent /&gt;<br>      &lt;AnotherHeavyComponent /&gt;<br>    &lt;/AppContext.Provider&gt;<br>  );<br>}</pre><p>The problem here is that when the state gets updated, App and all its children will re-render, which is expected because the state lives in App. But what I didn’t know was that there’s quite a simple solution to this problem.</p><p>If we move this state to a separate component and pass the other components as children, two things will happen:</p><ul><li>App will not re-render because state is no longer inside it; it now lives in a child component.</li><li>The children passed to this new component will not re-render because they also live in app</li></ul><p>And here’s how the code looks like:</p><pre>function App() {<br>  return (<br>    &lt;AppContextProvider&gt;<br>      &lt;SomeHeavyComponent /&gt;<br>      &lt;AnotherHeavyComponent /&gt;<br>    &lt;/AppContextProvider&gt;<br>  );<br>}</pre><pre>function AppContextProvider({ children }: PropsWithChildren) {<br>  const state = useState({});<br><br>  return &lt;AppContext.Provider value={state}&gt;<br>    {children}<br>  &lt;/AppContext.Provider&gt;;<br>}</pre><p>Just this simple change improved the performance of my feature by a lot, now the only components that should re-render are the ones that access the context, but there’s more work to be done because even with this change, we could still cause un-necessary re-renders.</p><h4>Unstable Context Value</h4><p>The way context works is by checking if the provided value has changed to decide if the component consuming it should re-render or not. The problem here is that comparing Objects in React is a bit tricky, especially if you’re using functional components. Let’s look at the following code:</p><pre>function App() {<br>  const [state, setState] = useState({});<br><br>  return (<br>    &lt;AppContext.Provider value={{ state, setState }}&gt;<br>      {/*  */}<br>    &lt;/AppContext.Provider&gt;<br>  );<br>}</pre><p>If we look at what is being provided to the context as a value, we’re creating a new object that encapsulates our state and its setter. The problem with this is that every time App renders, this object is re-created, AppContext will compare it to the previous value and find that it’s a new object so everything relying on it should re-render even though state and setState did not change, the value of the context has changed.</p><p>And this is why React has a concept called memoization to help prevent such cases that rely on object comparisons. This is a new concept for me that I found very weird at the beginning but started to make sense the more I worked with React. The trickiest part was to know when to use memo and when it doesn’t add any value, most beginners including me tend to memoize everything they write.</p><p>The fix here is simple, we will use the built-in hook useMemo to make sure that as long as state and setState have not changed, we will always have the same context value.</p><pre>function App() {<br>  const [state, setState] = useState({});<br><br>  const value = useMemo(() =&gt; ({ state, setState }), [state, setState]);<br><br>  return &lt;AppContext.Provider value={value}&gt;<br>    {/*  */}<br>  &lt;/AppContext.Provider&gt;;<br>}</pre><h4>Large Context Values</h4><p>One last thing that is very common to see in big React apps is placing everything inside one context; I have seen huge objects being passed to a single context, even though these objects are memoized, if one single variable has changed, the entire object will get re-created and every component that relies on this context in your big feature will get re-rendered.</p><pre>const value = useMemo(<br>  () =&gt; ({ object1, object2, object3, object4, object5, object6, object7, object8, object9, object10 }),<br>  [object1, object2, object3, object4, object5, object6, object7, object8, object9, object10]<br>);<br><br>return &lt;AppContext.Provider value={value}&gt;{/*  */}&lt;/AppContext.Provider&gt;;</pre><p>The best thing to do in this case is split the state over multiple contexts if it makes sense. For example, we like to split the state variables from the state setters and other callbacks for small to medium features, and for large features, we break it down into smaller sub-features and each one will have its own context.</p><h3>Conclusion</h3><p>These are not the only 3 bad practices in React, but they are the most common for a beginner and by following the above suggestions you should be able to at least double the performance of your application without having to dive into memoizing every single component in the application. If the top-level components are optimised, optimising the small child components is unnecessary most of the time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=377117197ef4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/outreach-prague/what-i-learned-after-switching-from-flutter-to-react-377117197ef4">What I learned after switching from Flutter to React</a> was originally published in <a href="https://medium.com/outreach-prague">Outreach Prague</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>