Skip to content
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

Merged
merged 8 commits into from
Jan 24, 2018

Conversation

t3chguy
Copy link
Member

@t3chguy t3chguy commented Jan 17, 2018

Replaces #5863

Fixes #5853

Signed-off-by: Michael Telatynski [email protected]

Copy link
Contributor

@lukebarnard1 lukebarnard1 left a 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 {
Copy link
Contributor

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).

Copy link
Contributor

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,
Copy link
Contributor

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);
Copy link
Contributor

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.

Copy link
Member Author

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

Copy link
Member Author

@t3chguy t3chguy Jan 23, 2018

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 <[email protected]>
Signed-off-by: Michael Telatynski <[email protected]>
Signed-off-by: Michael Telatynski <[email protected]>
@lukebarnard1 lukebarnard1 merged commit 394d4cf into develop Jan 24, 2018
@t3chguy t3chguy deleted the t3chguy/highlight_things branch May 12, 2022 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants