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

conditionally rendered link issue#2546 #2641

Merged

Conversation

hjhimanshu01
Copy link
Contributor

@hjhimanshu01 hjhimanshu01 commented Mar 17, 2019

What this PR does

Conditionally renders link in ArticleViewer , issue#2546

@@ -328,7 +328,9 @@ const ArticleViewer = createReactClass({
<div className="article-header">
<p>
<span className="article-viewer-title">{trunc(this.props.article.title, 56)}</span>
<span><a className="icon-link" href={`?showArticle=${this.props.article.id}`} /></span>
{this.props.article.id === 'undefined' && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this would/should be able to === 'undefined' as triple equals is used for strict equality. If there is no id, the value should be undefined, not a string with the contents 'undefined'.

A perhaps simpler way to do this is to just use !this.props.article.id.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! My bad ! , that's a grave mistake on my part .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you try this out? I think we were both wrong here. Instead, it should be:

this.props.article.id && ( ... )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely right !, had tested it with 'undefined' keyword , made changes

@ragesoss ragesoss merged commit 90b7858 into WikiEducationFoundation:master Mar 25, 2019
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.

None yet

3 participants