Anchors
note
Anchors are rendered with an internal renderer. See βRendering page. The content model of anchors is βmixed
, see βElement Models.
#
Minimal Examplenote
By default, pressing an anchor will open the link in the system browser. This is done with React Native βLinking
API.
#
Block ExampleIn 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.
#
Relative URLsThe 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:
tip
You can use the same URL normalization mechanism in your custom renderers thanks to βuseNormalizedUrl
hook.
#
ConfiguringWe can take advantage of the βrenderersProps
to customize anchors behavior (see βRenderersProps.a
). Anchors support onPress
prop to handle press events.