JavaScript ESLint Rule on React Component: Method Render expected no return value eslint-rule-react-hooks,eslint rule react/prop-types,eslint

I can't for the life of me understand why anyone would even want this rule let alone what it means. I want to return something here in the render

export default class SearchTabs extends Component {
  render() {
    const { panels, selectedTab } = this.props;
    if (!panels || panels.length === 0) return;

    let filter = null;

    const tabs = panels.member.map((panel, idx) => {
      const { id: panelId, headline } = panel;
      const url = getHeaderLogo(panel, 50);
      const item = url ?
        <img src={url} alt={headline} /> : headline;
      const classname = classNames([
        searchResultsTheme.tabItem,
        (idx === selectedTab) ? searchResultsTheme.active : null,
      ]);

      filter = (idx === selectedTab) ? this.renderFilters(panel) : filter;

      return (
        <TabItem
          classname={`${classname} search-tab`}
          headline={headline}
          idx={idx}
          content={item}
          onclick={() => {
            this.tabChanged(idx, headline);
          }}
          panelId={panelId}
        />
      );
    });

    return (
      <div className={searchResultsTheme.filters}>
        <ul className={`${searchResultsTheme.tabs} ft-search-tabs`}>{tabs}</ul>
        <div className={searchResultsTheme.dropdown}>{filter}</div>
      </div>
    );
  }
}
Answer:1

I believe your problem is the line

if (!panels || panels.length === 0) return;

It's complaining because this code path does not return anything. Try changing it to

if (!panels || panels.length === 0) return null;
Answer:2

Its because of this, if (!panels || panels.length === 0) return;. EsLint warns if return types are ambiguous because this returns undefined and later a ReactDom object.

simply if (!panels || panels.length === 0) return null; and it should be fine.

Answer:3

I am trying to extract "animal" and "fish" hashtags from the JSON object below. I know how to extract the first instance named "animal", but I have no idea how to extract both instances. I was ...

I am trying to extract "animal" and "fish" hashtags from the JSON object below. I know how to extract the first instance named "animal", but I have no idea how to extract both instances. I was ...

What does mean 'get' inside a javascript function?. This 'get' is used many time in the return. I stumbled upon this code: var getHost = function () { return { get linux() { ...

What does mean 'get' inside a javascript function?. This 'get' is used many time in the return. I stumbled upon this code: var getHost = function () { return { get linux() { ...

  1. what does mean in math
  2. what does mean mean
  3. what does mean in text
  4. what does mean in python
  5. what does mean in excel
  6. what does mean in java
  7. what does mean in measuring
  8. what does mean in c++
  9. what does mean in r
  10. what does mean in spanish
  11. what does mean on snapchat
  12. what does mean in javascript
  13. what does mean in sql
  14. what does mean in geometry
  15. what does mean in statistics
  16. what does mean in coding
  17. what does mean national emergency
  18. what does mean absolute deviation mean
  19. what does mean in matlab
  20. what does mean in linux

I would like to draw a horizontal target line showing threshold limits on a line, bar and pie chart using EChart.JS (https://ecomfe.github.io/echarts-doc/public/en/index.html). There are other ...

I would like to draw a horizontal target line showing threshold limits on a line, bar and pie chart using EChart.JS (https://ecomfe.github.io/echarts-doc/public/en/index.html). There are other ...

I have a top page which contains an iframe with untrusted content. I am hosting the untrusted content on a domain that I control, and can (in theory) make changes to it. Short of analyzing the source ...

I have a top page which contains an iframe with untrusted content. I am hosting the untrusted content on a domain that I control, and can (in theory) make changes to it. Short of analyzing the source ...