JimLiu / bbcode-to-react

A utility for turning raw BBCode into React elements.
MIT License
24 stars 21 forks source link

Only lowercase tags are allowed to register #11

Open CoenWarmer opened 6 years ago

CoenWarmer commented 6 years ago

When upgrading to React 16.4 we noticed some weird behavior. Tags that used to be recognized by the bbcode-to-react parser were suddenly being displayed as text.

After doing some research, we found out that when registering tags for the parser, the first argument passed needs to be all lowercase. Even if the tag in the content string that is passed is not all lowercase.

So, if you register your tag like this, the tag will be recognized by the parser: parser.registerTag('centeredimage', ImageCenteredTag)

If you register your tag like this, the tag will not be recognized by the parser: parser.registerTag('centeredImage', ImageCenteredTag)

Interestingly, it doesn't matter which content string you pass to the parser, both will work. So the content string can be [centeredimage] or [centeredImage].

This is not a huge issue, and everything works as expected, but I just wanted to report these findings so other users can take note.