Benjamin-Dobell / react-native-markdown-view

MarkdownView for React Native
MIT License
190 stars 77 forks source link

Warning when using custom rule (order attribute) #30

Open theohdv opened 6 years ago

theohdv commented 6 years ago

When adding customs rules to the component, always get this warning:

Warning: Failed prop type: Invalid prop `rules.MENTION_RULE.order` of type `number` supplied to `MarkdownView`, expected `function`.

My code:

  const TAG_RULE = {
    order: 1,
    match: (source, state, lookbehind) => /^\{tag\}(.*?)\{\/tag\}/.exec(source),
    parse: (capture, recurseParse, state) => ({ content: capture[1] }),
    render: (node, output, state, styles) => (
      <Text
        key={node.content}>
        {node.content}
      </Text>
    ),
  }

I don't know what order attribute is for, but if I just remove it, it shows me a new warning and If I try to supply a function it does not work anymore. I don't know if this warning has an impact or not but if not, it should be ignored and removed.

alexisab commented 6 years ago

I have the same problem. I try to add a custom rule that is quite similar to the link rule. I want my custom rule executed before the link rule so I have added this order property to my rule object :

{
    order:  SimpleMarkdown.defaultRules.link.order - 0.5,
    ...
}

But it doesn't work and if I tranform it into a function it doesn't work either.

sslash commented 5 years ago

Same here!

mixa9269 commented 4 years ago

Same here