native-html / plugins

Plugins for react-native-render-html
MIT License
55 stars 18 forks source link

how to add additional rule inside alterNode function? #3

Closed azuddin closed 5 years ago

azuddin commented 5 years ago

having difficulties on how to add additional condition to alterNode function without overriding it. other than manually updating the package, is there any way to do it? i wanted to add these to alterNode function

if (node.name === "img") { node.attribs = { ...(node.attribs || {}), style: height:"auto"; }; }

azuddin commented 5 years ago

Nvm, just found the solutions.

import { alterNode as alterNodeTable } from "react-native-render-html-table-bridge";

<HTML alterNode={node => {
   const { name, parent } = node;
   alterNodeTable(node);
   if (name === "img") {
         node.attribs = {
             ...(node.attribs || {}),
             style: `height:"auto";`
        };
        return node;
   }
}}/>