Error when "font-weight" is present on html
See original GitHub issueWhenever i try to render a page which contains font-Weight, i get the following error:
Warning: Failed prop type: Invalid prop fontWeight
of value 400
supplied to Text
, expected one of [“normal”,“bold”,“100”,“200”,“300”,“400”,“500”,“600”,“700”,“800”,“900”].
Bad object: {
“marginTop”: 14,
“marginBottom”: 14,
“fontWeight”: 400
}
in Text (at HTML.js:460)
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Error when "font-weight" is present on html · Issue #111 - GitHub
Whenever i try to render a page which contains font-Weight, i get the following error: Warning: Failed prop type: Invalid prop fontWeight of ......
Read more >font-weight is not working properly? - Stack Overflow
Its because the font size (9px) is too small to display bold. Try 11px or more and it works ...
Read more >font-weight - CSS: Cascading Style Sheets - MDN Web Docs
The font-weight CSS property sets the weight (or boldness) of the font. The weights available depend on the font-family that is currently ...
Read more >Alignment, font styles, and horizontal rules in HTML documents
This attribute takes the following values: left: Floats the object to the current left margin. Subsequent text flows along the image's right side....
Read more >HTML DOM Style fontWeight Property - W3Schools
The fontWeight property sets or returns how thick or thin characters in a text should be displayed. Browser Support. Property. fontWeight, Yes, Yes,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I stumbled upon a weird issue which caused this error in the following HTML:
with
fontWeight: '500'
set intagStyles
for bothh5
andstrong
.After removing
<strong>
or<img>
everything works properly. It seems that the string value gets converted to a number in the childText
component. I managed to find a hacky way to get around this by modifying source code of this library from https://github.com/archriss/react-native-render-html/blob/60d53598e35f5cf36d89a5c9a526d85a9744288f/src/HTMLStyles.js#L143 toI’m not sure if this is the right way to tackle this problem though and if it would not cause some other issues. Do you have any suggestions?
@Exilz Yes, you’re right - my initial solution would result in problems with other styles like
margin: 3
orfont-size: 12
(withoutpx
). Filtering justfontWeight
is enough for now I guess. I’ll try to submit a PR later tonight.