DEV Community

Ramesh Vishnoi
Ramesh Vishnoi

Posted on • Edited on

1

React Native Interview Questions

How to build Custom Native Modules?

  • Create module class extending ReactContextBaseJavaModule
  • Export module name and functions annotated as @ReactMethod
  • In MainPackage file, add newly created module into module list.
  • Import NativeModule from react-native package in JS file.
  • More Info here

How to build Custom Native UI Components?

  • Create ViewManager Subclass
  • Expose properties annotated as @ReactProps
  • Register your ViewManager Class
  • Create your View Class
  • More Info here

Number of threads in React Native?

  • Javascript thread which handles business logic, api calls, touch events
  • Main thread which handles Native logic

What are common Performance bottleneck or issues?

  • Usage of large ScrollView instead of ListView or FlatList
  • Unnecessary rerendering without UI changes
  • Improper usage of Keys. Read more here
  • Heavy Animation (Animation are calculated on Javascript thread). Use useNativeDriver as true to use native apis and move computation to main thread

How to Improve Performance?

  • use hermes engine
  • use inline requires for expensive or large module for eg :
let VeryExpensive = null;
const Home = () => {
    const onClickHandler = () => {
        if (VeryExpensive == null) {
            VeryExpensive = require('./VeryExpensive').default;
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

What is hermes?

  • Opensource JS engine optimized for React Native
  • Help in improved App startup time, decreased memory usage and smaller app size
  • More info here

What is Turbomodules?

  • Rearchitecture of Native Module system
  • Will help in facilitate more efficient typesafe Communication between JS and Native without React Native bridge

How to Animated stuff?

  • Use inbuild Animated apis for declarative animation between Input and Output
  • Use LayoutAnimation API for all animating Views in next render cycle. Mostly used for flexbox layout update

Sentry mobile image

App store rankings love fast apps - mobile vitals can help you get there

Slow startup times, UI hangs, and frozen frames frustrate users—but they’re also fixable. Mobile Vitals help you measure and understand these performance issues so you can optimize your app’s speed and responsiveness. Learn how to use them to reduce friction and improve user experience.

Read full post →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay