which should scroll to which should scroll to which should scroll to

How to scroll to an anchor in react-native-render-html

370 Views Asked by At

Problem

I get some html from an api endpoint. This html contains internal links like this: <a href="#my-item" /> which should scroll to <a id="my-item" href="#">My Item</a> when clicked.

My problem is that the default behavior for rendered links in react-native-render-html is this:

By default, pressing an anchor will open the link in the system browser. This is done with React Native ​Linking API.

That is not the desired behavior, I want it it auto-scroll to the correct tag.

Code

How can I accomplish this? I have specified a custom onPress function for <a/> tags, but how can program the default browser behavior?

  const renderersProps = {
    a: { onPress: handleLink },
  };
0

There are 0 best solutions below