Mobile Development

React Native 0.85 Unleashed: A New Animation Era, Enhanced DevTools, and Crucial Updates

The React Native team has officially launched version 0.85, a significant release poised to redefine animation performance and developer experience within the cross-platform mobile development landscape. This latest iteration introduces a groundbreaking New Animation Backend, streamlines the Jest testing setup by migrating its preset to a dedicated package, and incorporates a multitude of other enhancements and bug fixes aimed at bolstering stability and efficiency for developers worldwide. The release marks a pivotal moment, particularly with its ambitious overhaul of the animation system, a long-standing area of focus for optimization.

The introduction of the New Animation Backend represents a substantial leap forward. Developed in close collaboration with the expert team at Software Mansion, this new internal engine forms the core of how animations are processed under the hood for both React Native’s native Animated API and the popular community-driven Reanimated library. By centralizing the primary animation update logic within the React Native core, this architectural shift unlocks performance improvements previously unattainable. Crucially, it ensures a more robust and tested reconciliation process, promising greater stability as React Native evolves.

One of the most immediate and impactful benefits of this new backend is the expanded capability within the Animated API. Developers can now animate layout properties, such as flex and position values, directly using the native driver. This addresses a significant limitation that previously restricted the native driver’s application to transform and opacity properties. The implications are far-reaching, enabling smoother, more performant animations for complex UI elements and transitions that were once challenging to implement efficiently. The team has provided illustrative examples within the react-native/packages/rn-tester/js/examples/AnimationBackend/ directory on GitHub, offering developers a practical starting point to explore these new possibilities.

To access this cutting-edge animation technology, developers can opt into the experimental channel of React Native, as detailed on the official React Native releases documentation. It is important to note that this experimental feature will become fully available starting with React Native 0.85.1, a subsequent release scheduled for the immediate future, ensuring a stable rollout.

The ability to animate layout props with the native driver opens up a world of possibilities for richer user interfaces. Previously, animating properties like width, height, margin, padding, or top/left would often fall back to the JavaScript thread, potentially leading to jankier animations, especially on lower-end devices or during complex view manipulations. With React Native 0.85’s enhanced animation backend, these layout-related animations can now be handled entirely on the native thread, leading to significantly smoother and more responsive visual experiences. This is particularly beneficial for dynamic layouts, expandable content sections, and intricate screen transitions that rely heavily on animated spatial adjustments.

A practical demonstration of this new capability can be seen in the following code snippet, showcasing how to animate a width property:

import 
  Animated,
  Button,
  View,
  useAnimatedValue,
 from 'react-native';

function MyComponent() 
  const width = useAnimatedValue(100);
  const toggle = () => 
    Animated.timing(width, 
      toValue: 300,
      duration: 500,
      useNativeDriver: true,
    ).start();
  ;

  return (
    <View style=flex: 1>
      <Animated.View
        style=width, height: 100, backgroundColor: 'blue'
      />
      <Button title="Expand" onPress=toggle />
    </View>
  );

This example clearly illustrates how a simple Animated.timing call, with useNativeDriver set to true, can now effectively animate the width of an Animated.View, resulting in a fluid expansion animation handled by the native platform.

Beyond the animation overhaul, React Native 0.85 also brings significant improvements to the React Native DevTools. These enhancements aim to streamline the debugging and inspection process for developers. While specific details of all DevTools improvements are often incremental, the inclusion of features like native tabs on macOS, as depicted in accompanying screenshots, suggests a focus on improving the integration and usability of the development environment across different operating systems. This attention to developer tooling is crucial for maintaining developer productivity and facilitating faster iteration cycles.

Furthermore, the Metro development server, the heart of React Native’s build and bundling process, now boasts TLS support. This addition allows the Metro dev server to accept a TLS configuration object, enabling HTTPS and WSS (for Fast Refresh) during development. This is a vital feature for developers working with APIs that enforce secure connection requirements, as it allows for more realistic testing environments without the need for complex workarounds or disabling security protocols. Developers can configure this by adding a tls object to the server configuration in their metro.config.js file, specifying paths to Certificate Authority (CA), certificate, and key files. For local development convenience, tools like mkcert are recommended for generating locally trusted certificates without triggering browser warnings.

React Native 0.85 - New Animation Backend, New Jest Preset Package

In terms of breaking changes, developers will need to be aware of a few key adjustments. The Jest preset, previously bundled within the main react-native package, has been extracted into a new, dedicated package: @react-native/jest-preset. This move serves to reduce the core package size and offers greater flexibility in testing configurations. Migrating is a straightforward, one-line change in jest.config.js, updating the preset property from 'react-native' to '@react-native/jest-preset'.

Another significant breaking change is the dropped support for end-of-life (EOL) Node.js versions, specifically targeting releases prior to v20.19.4. Developers are strongly advised to ensure they are running a supported version of Node.js before attempting to upgrade to React Native 0.85. This move aligns React Native with current Node.js LTS (Long Term Support) policies, promoting the use of stable and actively maintained JavaScript runtimes.

The deprecated StyleSheet.absoluteFillObject API has also been removed. Developers should now transition to using StyleSheet.absoluteFill or define their absolute positioning styles manually. This change, while minor, encourages the use of more current and explicit styling practices.

The release notes also indicate a series of other breaking changes categorized under "General," "Android," and "iOS," though specific details for these are not elaborated upon in the provided content. This implies a need for developers to consult the full release notes and potentially perform thorough testing after upgrading, especially if their projects have platform-specific native code or dependencies.

The release of React Native 0.85 is the culmination of over 604 commits contributed by a dedicated community of 58 developers. This collaborative effort underscores the vibrant ecosystem surrounding React Native. The team extends its gratitude to all contributors, with special acknowledgment given to those who made significant contributions to this release and to those who have helped document the new features.

For existing projects, the React Native Upgrade Helper tool remains the indispensable resource for navigating the transition to 0.85, providing detailed code change comparisons. For those embarking on new projects, initializing with the latest version can be done using the command: npx @react-native-community/cli@latest init MyProject --version latest.

For users of the Expo managed workflow, React Native 0.85 will be integrated into the upcoming SDK 56, ensuring that Expo developers can leverage these new features once the SDK is released. This strategic integration highlights the ongoing collaboration between the React Native core team and the Expo team, providing a unified development experience.

The support policy for React Native versions has also been updated, with 0.85 now designated as the latest stable version, and versions in the 0.82.x series moving to an unsupported status. This aligns with the project’s commitment to maintaining a focused set of actively supported releases, allowing the team to concentrate on delivering new features and critical fixes. Developers are encouraged to review the React Native support policy for detailed information on version lifecycles.

In summary, React Native 0.85 represents a significant advancement, particularly in its revolutionary approach to animation performance. The introduction of the New Animation Backend, coupled with enhancements to developer tooling and crucial updates to core functionalities, positions this release as a must-adopt for developers seeking to build high-performance, engaging mobile applications efficiently and effectively. The continuous dedication of the React Native community and core team ensures that the platform remains at the forefront of cross-platform development innovation.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button