You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
React has shorthand for specifying pixel values in style. So when you put into HTMLtoJSX something like this <div style="line-height: 50px;"></div>'
it produces <div style={{lineHeight: 50}}>
The problem is that line-height acceptes plain values (like line-height: 50), so the above JSX is actually sets line-height style for 50, not 50px.
Reacted by Shinse Tanaka, archived profile , Neu and Omar López
@Daniel15 Why modify those values at all? React 16 will stop appending 'px' for CSS values, so that modification will potentially break. Can HTMLtoJSX simply use the values verbatim?
@ssorallen - That changelog entry only applies to strings (eg. {{width: '123'}}, not numbers (eg. {{width: 123}}). The behaviour for numbers remains unchanged.
Having said that, there's no harm in keeping the px suffix, so maybe HTMLtoJSX should just use it verbatim.
@ssorallen - That changelog entry only applies to strings (eg. {{width: '123'}}, not numbers (eg. {{width: 123}}). The behaviour for numbers remains unchanged.
Having said that, there's no harm in keeping the px suffix, so maybe HTMLtoJSX should just use it verbatim.
{
..."rules": {
"no-restricted-syntax": [
"error",
{
"selector": "Property[key.name=lineHeight] > Literal[value=/([0-9]+)[^px]$/]",
"message": "Make sure to specify an unit when using lineHeight (see React issue: https://github.com/reactjs/react-magic/issues/53)"
}
]
}
}
Activity
Daniel15 commentedon Apr 18, 2016
Good catch, we probably need to special-case
line-height. May need some special case here: https://github.com/reactjs/react-magic/blob/master/src/htmltojsx.js#L127-L129Daniel15 commentedon Apr 25, 2016
Should determine where React pulls this blacklist from: http://facebook.github.io/react/tips/style-props-value-px.html
ssorallen commentedon Apr 25, 2016
@Daniel15 Why modify those values at all? React 16 will stop appending 'px' for CSS values, so that modification will potentially break. Can HTMLtoJSX simply use the values verbatim?
ssorallen commentedon Apr 25, 2016
https://facebook.github.io/react/blog/2016/04/07/react-v15.html#new-helpful-warnings
Daniel15 commentedon Apr 25, 2016
@ssorallen - That changelog entry only applies to strings (eg.
{{width: '123'}}, not numbers (eg.{{width: 123}}). The behaviour for numbers remains unchanged.Having said that, there's no harm in keeping the
pxsuffix, so maybe HTMLtoJSX should just use it verbatim.sizer commentedon Feb 12, 2018
any news about this issue?
Daniel15 commentedon Feb 14, 2018
@mrdShinse I don't think anyone has submitted a PR to fix it yet
drax10 commentedon Nov 19, 2018
If this is the case, this can be solved simply by removing these lines https://github.com/reactjs/react-magic/blob/master/src/htmltojsx.js#L727-L729 along with the
isConvertiblePixelValuefunction. Please advise if I'm missing some reason some styles need thepxsuffix omitted.Dont convert pixel values to integers.
Dont convert pixel values to integers.
SkyzohKey commentedon Dec 4, 2018
ESLint rule so this behavior can be prevented.
{ ... "rules": { "no-restricted-syntax": [ "error", { "selector": "Property[key.name=lineHeight] > Literal[value=/([0-9]+)[^px]$/]", "message": "Make sure to specify an unit when using lineHeight (see React issue: https://github.com/reactjs/react-magic/issues/53)" } ] } }zomars commentedon May 30, 2022
I'm willing to make a PR if someone can tell me where I can add an exception for
line-height.EDIT: I see that you have this method to strip
pxvalues but I can't where is being used:react-magic/src/htmltojsx.js
Line 259 in b915f5a
Dont convert pixel values to integers.