ReactLynx is the official React framework for Lynx. It allows you to develop Lynx native apps with a React mental model.
With ReactLynx, you can build your UI using JSX and React components, just like you would on the web. ReactLynx turns your React code into calls to the Lynx Engine imperative API to render the native UI.
ReactLynx itself is an "idiomatic" React, but it also pioneered optimizations such as "dual-threaded React" and "JSX constant folding".
import
Since it has the same API as react
, you can directly replace react
with @lynx-js/react
, and continue to use the React API you are familiar with.
For a full list of APIs ReactLynx implemented, please refer to the @lynx-js/react
API documentation.
Unlike elements such as div
and span
on the Web, Lynx provides a set of native component sets, such as view
, text
, image
, etc (full list).
In ReactLynx, you can combine these elements to build your native UI.
While the naming of native components is similar to React Native, ReactLynx do have some differences:
Based on Lynx, ReactLynx uses a different set of event naming than the Web (go to Events to learn more).
Lynx does not have a complete corresponding API for methods such as e.stopPropagation()
and e.preventDefault()
that are commonly used on the Web. But Lynx's Event Propagation Mechanism allows you to implement similar functions or effects as on the Web.
document
and window
Lynx does not yet provide document
and window
objects, so ReactLynx does not support these two objects either.
Lynx Engine provides a set of Low Level Element APIs that allow Framework Developers to create UI through JavaScript running in the Main Thread. But this set of APIs is not open to all developers. Lynx encourages developers to use declarative methods to build UI as much as possible, rather than directly manipulating the DOM. But Lynx also provides the ability to Directly Manipulate Elements and Main Thread Scripts, which are generally used to help developers maintain a near-native user experience when implementing some complex interactions.
This means that you cannot use any libraries that depend on document
or window
.
There are basically two ways for this difference:
lynx
object like lynx.reload
to replace window.location.reload()
.If you haven't already, you should learn the basics of Lynx.