LG-3237: React internationalization string element interpolation#3997
LG-3237: React internationalization string element interpolation#3997
Conversation
There was a problem hiding this comment.
This gives me pause. Technically the u here is a component, and the rule should apply to all components. But I'm also motivated to not over-complicate how one interfaces with formatHTML to impose that they define a separate component function with its own propTypes, defaultProps, etc. Conversely, I could have chosen to not assign the "handlers" mapping with the value being of type Component, and instead more of a generic "function which returns an element". The nice thing about this usage is that you could choose to extract or reuse a traditional component here (e.g. { button: MyFancyButton }).
I see some value in having the rule in general, in how it's self-documenting and provides some availability of type-hinting for capable IDEs.
But it's also something where, if we decide to integrate more of the TypeScript tooling, it's completely redundant with standard JSDoc function parameter documentation (where the parameter is the props object of a particular shape).
**Why**: Localized strings may contain HTML markup, which React will escape by default. This provides a mechanism to be able to safely replace intended HTML markup with equivalent React elements substitutes.
**Why**: The implementation is acknowledged as naive. Use documentation to prevent developer from getting themself in trouble
**Why**: Clarifies that it relies on React interpolation to replace with styles
da980e9 to
5cae041
Compare
Why: Localized strings may contain HTML markup, which React will escape by default. This provides a mechanism to be able to safely replace intended HTML markup with equivalent React elements substitutes.
See inline code documentation for
formatHTMLfor more details, limitations, etc.