-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Highlight ViewSource and Devtools ViewSource #5995
Conversation
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
…:vector-im/riot-web into t3chguy/highlight_things
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good having tested it! (V. happy to see that (obviously) dev tools has likewise has been updated) 😀
import PropTypes from 'prop-types'; | ||
import {highlightBlock} from 'highlight.js'; | ||
|
||
export default class Highlight extends React.Component { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest renaming this to something more specific, maybe SyntaxHighlight
? (For the sake of not confusing this with highlighting messages).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(And also rename the related stuff, i.e. the CSS)
export default class Highlight extends React.Component { | ||
static propTypes = { | ||
className: PropTypes.string, | ||
children: PropTypes.node, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't do this anywhere, but having just seen this thread, I'd be happy to start doing this for clarity of "this component uses its children, see it's in the prop types". (and IRLd with @dbkr and he agreed, although we won't obsess over it.)
} | ||
|
||
componentDidUpdate() { | ||
if (this._el) highlightBlock(this._el); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this componentDidUpdate
is redundant, as we only call highlightBlock
if we have this._el
and we only have this._el
if _ref
has been called, which itself sets this._el
.
So I think you want to highlightBlock
in _ref
only?
If this isn't true, perhaps a comment would be nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I shall investigate this tomorrow after my Networks Exam :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So @lukebarnard1 componentDidUpdate
is used when being reused with new props, but won't work with componentWillReceiveProps
because it needs to happen once React is done updating
I'll add a comment
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Replaces #5863
Fixes #5853
Signed-off-by: Michael Telatynski 7t3chguy@gmail.com