Anchors
note
Anchors are rendered with an internal renderer. See βRendering page. The content model of anchors is βmixed, see βElement Models.
Minimal Example#
- JSX Source
- HTML Snippet
- TRT Snapshot
note
By default, pressing an anchor will open the link in the system browser. This is done with React Native βLinking API.
Block Example#
In the below example, the anchor will be translated to a βTNode node, because some of its children (β<img>) have a block content model. This is a feature of the mixed content model.
- JSX Source
- HTML Snippet
- TRT Snapshot
Relative URLs#
The HTML standard allows relative URLs, for example when anchors have a href attribute with no origin, such as <aΒ href="contact.html">. The new foundry release adheres closely to this standard, by extracting information about the baseUrl of the current page. Either by the mean of the β<base> element, or by information contained in the βsource prop. Example:
- JSX Source
- HTML Snippet
- TRT Snapshot
tip
You can use the same URL normalization mechanism in your custom renderers thanks to βuseNormalizedUrl hook.
Configuring#
We can take advantage of the βrenderersProps to customize anchors behavior (see βRenderersProps.a). Anchors support onPress prop to handle press events.
- JSX Source
- HTML Snippet
- TRT Snapshot