<?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 Anton Kalinin on Medium]]></title>
        <description><![CDATA[Stories by Anton Kalinin on Medium]]></description>
        <link>https://medium.com/@antik?source=rss-2426986c21ff------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FI6_DvpHx94eSoaF6IGKyA.jpeg</url>
            <title>Stories by Anton Kalinin on Medium</title>
            <link>https://medium.com/@antik?source=rss-2426986c21ff------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 13:10:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@antik/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[Building animated filters bar with React Native]]></title>
            <link>https://medium.com/jobtoday/building-animated-filters-bar-with-react-native-2bdde7a4f16c?source=rss-2426986c21ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/2bdde7a4f16c</guid>
            <category><![CDATA[react-native-web]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[ui]]></category>
            <dc:creator><![CDATA[Anton Kalinin]]></dc:creator>
            <pubDate>Sun, 21 Apr 2019 19:40:55 GMT</pubDate>
            <atom:updated>2019-04-21T19:40:55.362Z</atom:updated>
            <content:encoded><![CDATA[<h4>and React Native Web</h4><p>At JOB TODAY we are using React Native for Web and Mobile development. We’ve been talking about the unification process we went through in <a href="https://medium.com/jobtoday/one-react-to-rule-them-all-at-job-today-93f67d23b4fb">the previous article.</a></p><p>In this post I would like to describe the way we built <strong>animated filters bar</strong> using React Native (both for native and mobile web apps). I hope you’ll find it practical.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*_SBqLFAgMybwBk8hAtYuBA.gif" /></figure><p>Here are a few examples in case you want to check them out first:</p><ul><li>Expo example:<strong> </strong><a href="https://exp.host/@antonkalinin/animated-filters-example">https://exp.host/@antonkalinin/animated-filters-example</a></li><li>Mobile web example:<strong> </strong><a href="https://animated-filters.antik.now.sh/">https://animated-filters.antik.now.sh</a></li></ul><h3>Layout</h3><p>The main idea is to place fixed element over the top of the ScrollView which has left padding equal to the width of the sticky element.</p><p>Then wrap fixed element into Animated.View to make it work as a mask to hide part of the button while scrolling. In our case the mask has minimum width equal to the width of the filters icon.</p><p>There might be problem if filter’s sticky button has non determined width (for instance in case of different word length for different languages). So we can either predefine the map with widths of the buttons according to language or set onLayout to Animated.View to determine width of the button as if it’s been rendered for the first time.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1b526f3127e7fb8744e18c3128146a0/href">https://medium.com/media/f1b526f3127e7fb8744e18c3128146a0/href</a></iframe><h3>Animation</h3><p>So we want our fixed element to squeeze as we scroll filters bar. To achieve this we are going to animate width of the fixed element container that will operate like a mask for inner button.</p><p>The first part is pretty much trivial. We define new animated value as <em>animatedWidth</em>. In onFiltersScroll listener added as onScroll prop to ScrollView we change <em>animatedWidth </em>according to ScrollView content offset.</p><p>The main challenge is to handle the use case of releasing a finger by user while our sticky element is partially hidden. It’s either finishing the squeezing process or showing back the entire element.</p><p>So the overall tactic is to listen onScrollEndDrag event and decide the direction to scroll our ScrollView according to the content offset. As soon as user scrolls less than 1/2 of the button and stops we force scroll back, otherwise scroll forward and squeeze the button to its minimum size.</p><p>To make this behaviour look more natural we introduce a <strong>velocity factor</strong>: we put the horizontal velocity into equation to minimise the distance that shows in which direction to force scroll of the list.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a599789a19b6b3d8e6e0c947f1a9413/href">https://medium.com/media/0a599789a19b6b3d8e6e0c947f1a9413/href</a></iframe><h3>Is there a way to use the same component for Web?</h3><p>No doubt. It’s offered by <a href="https://github.com/necolas/react-native-web">React Native Web</a> which is really cool by the way. <br>But to make your web experience smooth enough there are some aspects you need to take into account.</p><p>For instance we use TouchableOpacity for filter buttons in React Native apps. In fact I would not use same component for web because this usage leads to “shaking behaviour” during rapid scrolling. It’s caused by <a href="https://csstriggers.com/opacity">opacity</a> css property that triggers a lot of repaints during the animation. In this case I would rather suggest to change TouchableOpacity to TouchableHighlight for web.</p><p>For instance:</p><pre>import { TouchableOpacity, TouchableHighlight } from &quot;react-native&quot;;</pre><pre>const Touchable = Platform.select({<br>  web: TouchableHighlight,<br>  default: TouchableOpacity<br>});</pre><p>Here is a GitHub repo with code of an example I mentioned above: <a href="https://github.com/jobtoday/animated-filters-example">https://github.com/jobtoday/animated-filters-example</a></p><p>That’s pretty much it. Hope, you’ve found it useful.</p><p>Let me know in the comments below what you think!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2bdde7a4f16c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/jobtoday/building-animated-filters-bar-with-react-native-2bdde7a4f16c">Building animated filters bar with React Native</a> was originally published in <a href="https://medium.com/jobtoday">JOB TODAY</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unifying mobile and web development with React Native]]></title>
            <link>https://medium.com/jobtoday/one-react-to-rule-them-all-at-job-today-93f67d23b4fb?source=rss-2426986c21ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/93f67d23b4fb</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[react-native-web]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Anton Kalinin]]></dc:creator>
            <pubDate>Thu, 29 Nov 2018 13:52:44 GMT</pubDate>
            <atom:updated>2019-04-21T17:55:11.526Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uWLb6AkXkmczGcdw1H1zDw.jpeg" /></figure><p>JOB TODAY is the world’s fastest growing hiring marketplace operating in the US and Europe. Millions of candidates trust JOB TODAY to find local jobs in restaurants, hotels, shops and more. Over 100 million candidate applications were delivered since launch in 2015. Our mission is to help everyone find work in 24 hours.</p><p>In April 2015, JOB TODAY was launched on iOS, followed by Android and only this year, in May, we released the first <a href="https://jobtoday.com/en/jobs/london">web version</a> of our service. Initially, our mobile applications were 100% native (Swift and Java). The team consisted of 4 mobile developers (1 Android, 2 iOS and 1 cross-platform) and 3 web developers.</p><p>As we continued to grow as a company, we decided to move to codebase unification and we selected React Native (RN). Our main reasons for moving to RN were quite common: we want to optimize and reuse our development resources which is crucial for a fast-growing startup. Gradually we migrated a significant amount of components to React Native.</p><blockquote><strong><em>Coincidentally, whilst we’re actively rewriting our app to React Native, a huge wave of negative </em></strong><a href="https://medium.com/airbnb-engineering/react-native-at-airbnb-f95aa460be1c"><strong><em>posts</em></strong></a><strong><em> about this framework have been published. We carefully read many of them and calmly continued our development :)</em></strong></blockquote><p>We needed a web app that would provide the same functionality for our users as native apps already do. We decided to not stop here in unifying our codebase: we looked at React Native for Web which was running <a href="https://mobile.twitter.com/home">Mobile Twitter PWA</a> and with which we were able to use our React Native components in web. We decided to write simple web app reusing native components with <a href="https://github.com/necolas/react-native-web">React Native for Web</a> first and then review and refactor modules and components to make them extendable and work properly in all our web and native apps.</p><p>After the first web version was released we did a code freeze for all apps and started refactoring. I’d like to share several of the architectural problems we came across and how we solved them.</p><h3>Synchronous development for web and native</h3><p>One of our main problems was the process of synchronous development for web and native, which was inconvenient and not optimised. Although web development was usual, with webpack server that provided fresh bundle after every source change. This was not the same case for iOS and Android apps. These apps were brownfield and over time we started to use React Native components as NPM private packages, however, development was carried out in sandbox (Storybook). In simpler terms, it was impossible to make changes in source code and immediately see them in native apps.</p><p>iOS and Android apps still have a native skeleton and we needed to combine this skeleton with React Native views. To initialise screens, navigate to them, handle and delegate events between native and JS sides via bridge. So we came to the concept of <em>manager</em> (internally we called it <em>shell</em>) which can take a JS bundle provided by <a href="https://facebook.github.io/metro/">metro</a> and do all the functions listed above.</p><p>At the same time <em>manager </em>is<em> </em>connected to apps as <a href="http://artsy.github.io/blog/2018/04/17/making-a-components-pod/">pod library</a> in case of iOS and as module for Android.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JSxk6hhMpXFl9RubRRm72A.png" /></figure><p>Manager is configured with a special app-structure.json file that tells the app where to get the bundle, what global props it has and which screens are contained. This configuration gives us flexibility, for instance by duplicating managers so that we have different bundles and several apps in one (for different user roles for instance) or do A/B tests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nH-Wi1jrveQwXzcHUmqEtA.png" /></figure><p>Another function of manager is to navigate between screens. We use our own native implementation of navigator which can push, pop and present scenes. To make this work, we register each screen independently via AppRegistry with a unique key. The same key is set in the structure json file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lTaq_uonUo3E1wWHFdvy6w.png" /></figure><p>Each screen is also enhanced with withNativeBridge<em> </em>and withNavigation HOCs which wraps components with contexts to allow retrieve navigation state and dispatch events to native side over the bridge. We also wrap screens with redux provider that uses same instance of store.</p><h3>Folders and files structure</h3><p>The changes described above led us to the problem that our modules were still oriented to work only either with native or web app. But our needs were to use them everywhere so we came to the next file structure inside the module:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hGeZQjFU4fj-9IXlFkICxQ.png" /></figure><p>This new structure allowed us to have separated imports such as:</p><p>import ScreenScene from &quot;@jobtoday/module-screen/native”</p><p>for each platform and store common parts. Each level (common, web or native) could have a components folder. We decided to organise scene files that present app screens as a combination of <em>container</em> and <em>layout</em> components. Container almost always stores in the common directory, connected to the Redux store and contains all the business logic that as props, goes to Layout. We found it very convenient to use the <a href="https://reactjs.org/docs/render-props.html">“render prop”</a> approach here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qgtSGHYA65IlcFDb6BELRg.png" /></figure><p>This approach defines the place where we can decide which layout, desktop or mobile we need to render.</p><h3>Rolling in the deep</h3><p>Using the “render prop” approach, we found ourselves passing a lot of handlers from container down to the child components which should call them. onItemSelected, onSavePressed, onTabChanged and many others were making our components hard to read and also hard to understand how every handler changed during its travel into the deep.</p><p>Here we took some ideas from redux and added localDispatch method to containers:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NZz3eRufXGilqiiDYQIuTQ.png" /></figure><p>It allowed us to pass only one handler through all layers and call it with different event types. By calling events unique names like @SCREEN_SOME_ACTION we are able to easily find the call source and the handler.</p><h3>To navigate same way</h3><p>We would like to have more flexibility, which is why in native apps we implemented navigation that allows us to show either a native or React Native screen. In web app, we are using React Router. Both techs work fine for us but we also wanted to have the same API to call navigation in common components. The problem was that in native app, we needed to call a function in response to a touch event, on the other hand in web we just needed to provide a string href attribute. We created a component Link and started experimenting with props unification. Finally we came to next implementation for Link.native.js:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ueBkk2vistLwgl4otYBfhg.png" /></figure><p>And Link.web.js:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mpERexfHYEck8u-ilAkp8w.png" /></figure><p>As you can see both components have an identical API and can be used as follows:</p><p>&lt;Link.Screen state={{key: 123}} /&gt;</p><p>We found several advantages by doing it this way. One main advantage is that we can specify <a href="https://flow.org/">Flow</a> type for state that a certain link accepts. This helps us a lot during development and refactoring. Another advantage is that now we can easily find all the places where we navigate to job screen just by searching Link.Job :)</p><blockquote><strong><em>It is interesting that we came up with this implementation on our way to Subway when we were loudly discussing the problem. Afterwards I found that research has shown that people are more creative when they are walking. It seems to work!</em></strong></blockquote><h3>And where we came</h3><p>It took 3 months to develop and refactor old parts, including summer vacations. We released web and iOS almost at the same time and Android, as usual, for React Native projects came after. The biggest reward for us is that our main KPIs weren’t affected in any negative way after release. More over we can improve some metrics on web by porting a better user experience from native clients and unifying UI.</p><h4>Team</h4><p>Now, we are 8 developers and each of us can implement a new feature or fix a bug in common code. We’ve got the interchangeability that we wanted and what was so important for this project. Of course we still have some native or web parts which require deep platform knowledge so not every one of us can deal with it. But in most cases each of us can solve daily basis tasks, do code review or build a new version.</p><h4>Code sharing</h4><p>It is hard to count precisely the proportion between common code and platform specific code. But to show how much approximately we share I took the most popular screen in our service, job screen, and count lines of JavaScript code for common, web and native parts.</p><ul><li><strong>~7000</strong> LOC of common code (components, actions, reducers, selectors)</li><li><strong>200 </strong>LOC for native part</li><li><strong>850 </strong>LOC for web part</li></ul><p>Even though the numbers may not be very accurate, the proportion of common code is an order of magnitude larger.</p><h4>Impressions</h4><p>In the first sprint after we released common code base, one of our product tasks was to add a similar jobs list to the job screen in both of our apps and web. This was done by one person in 4 days, easy and effective. This is what we were going for.</p><p>Of course there cannot be only advantages, having bugs in common code will lead to bugs across all 3 platforms. And sometimes common code boundaries add extra complexity in certain solutions. But we are aware of this trade off and think these are not unsolvable problems.</p><p>We are still getting used to working with common code base: looking for better practice to organise testing and deploy processes, optimising web experience, choosing the right balance between native, react-native and web. We still have a lot of things to do. But I think we now have a good base to work on and it will help us grow as team and company.</p><p>I look forward to sharing more about our experience and best practices of living with common code for native and web in upcoming stories.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93f67d23b4fb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/jobtoday/one-react-to-rule-them-all-at-job-today-93f67d23b4fb">Unifying mobile and web development with React Native</a> was originally published in <a href="https://medium.com/jobtoday">JOB TODAY</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>