Experiments with High Performance Animation in React Native

Three major methods for shape animation with React Native via @salesforceeng

  • This story is my experience and experiments to achieve high performance animation in React Native.Along the way I learned tons from these blogs and recommend you read them as you dive deeper into building your own animations in React Native:React Native Animations Using Animated API from Nader DabitReact Native ART and D3 from Harry WolffBefore we continue, I would like to define what “high performance animation” in terms of my project.
  • Note: There is another OpenGL binding for React Native which enables a more flexible OpenGL implementation without the interface.Animation in React NativeIn my exploration I tested three major methods (with some variations) for doing shape animation with React Native.
  • For example, if we have a shape with a 1px border, it cannot be transformed to have a larger width/height and retain the same border width without redrawing.Experiments and ResultsRequest Animation Frame + JavaScript tweeningThe first approach is to change nothing but use the same code from the web implementation — meaning everything is done in JavaScript without any help from React Native.
  • The gaps between each country will also get scaled so the transformed shapes are not the same as the new shapes.Zoom animation with fade in/outThis method has a significant impact on the memory footprint since there are two views with a shadow node per shape.Animated + Hybrid Native Driver + Animated Shape (ART)For this approach I still used the Native Driver while I found there is a trick to communicate between the JS thread and UI thread using setNativeProps.
  • I first tried with React Native ART and switched to React Native SVG while both give similar results.Animated + Hybrid Native Driver + Animated Shape (OpenGL)After realizing the bottleneck comes from re-drawing shapes, I switched to another library which has the drawing logic implemented in OpenGL.

Archiving decent animation performance is quite tricky. This story is my experience and experiments to achieve high performance animation in React Native.
Continue reading “Experiments with High Performance Animation in React Native”

GraphQL the future for APIs? – Ideas2IT – Medium

GraphQL the future for APIs?
#Graphql #Reactjs #js #API #CloudComputing

  • Your client requests data in one request even in slow mobile network connections.
  • GraphQL is a query language for your API, and a server-side runtime for executing queries by using a type system you define for your data.
  • Rather than construct several REST requests to fetch data that you’re interested in, you can often make a single call to fetch the information you need.
  • We think though GraphQL is backed by big companies, thinking in Graphs seems to be good fit for your data and kind of topology.
  • The post throws insights on why GraphQL is the future for APIs.

There has been a lot of buzz about GraphQL recently. GraphQL name rings bell in most of conferences around the world. There were a number of GraphQL sessions in the recent ReactEurope tour. This post…
Continue reading “GraphQL the future for APIs? – Ideas2IT – Medium”

Things I wish I knew about Redux — Horrible Hacks — Medium

Things you wish you knew about Redux:  #ReactJS

  • Use reselect sparingly, use props in selectors even more sparingly.
  • If you have a selector that uses props and is shared across multiple components, you will end up with a performance nightmare.
  • Every time I use somebody else’s boilerplate, I would spend hours trying to get it to work.
  • It took a few weeks for me to find somebody else using a “selector” in mapStateToProps .

Read the full article, click here.

@ReactiveConf: “Things you wish you knew about Redux: #ReactJS”

I’ve been working on React/Redux apps for about a year. I wish I knew these things when I started.

Things I wish I knew about Redux — Horrible Hacks — Medium