mirror of
https://github.com/strapi/strapi.git
synced 2025-11-30 17:18:24 +00:00
Fix conditional logic
Original code: ```js const listTitle = this.props.match.params.slug === 'languages' || 'databases' ? this.renderListTitle() : ''; ``` Is interpreted as: ```js const listTitle = ( this.props.match.params.slug === 'languages' || 'databases' ) ? this.renderListTitle() : '' ; ``` Been `databases` always been evaluate as `true`, this is the same that: ```js const listTitle = this.renderListTitle(); ``` Clearly is not the intention. I refactor this peace of code with what I think was the real intention; looking just the code, not knowing is this is the desire behavior
This commit is contained in:
parent
ff003a6b58
commit
d7ffb9e50e
@ -397,8 +397,8 @@ export class HomePage extends React.Component { // eslint-disable-line react/pre
|
||||
// if custom view display render specificComponent
|
||||
const Component = this.components[specificComponent];
|
||||
const addRequiredInputDesign = this.props.match.params.slug === 'databases';
|
||||
const listTitle = this.props.match.params.slug === 'languages' || 'databases' ? this.renderListTitle() : '';
|
||||
const listButtonLabel = this.props.match.params.slug === 'languages' || 'databases' ? this.renderListButtonLabel() : '';
|
||||
const listTitle = ['languages', 'databases'].includes(this.props.match.params.slug) ? this.renderListTitle() : '';
|
||||
const listButtonLabel = ['languages', 'databases'].includes(this.props.match.params.slug) ? this.renderListButtonLabel() : '';
|
||||
|
||||
// check if HeaderNav component needs to render a form or a list
|
||||
const renderListComponent = this.props.match.params.slug === 'databases';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user