react ESLint(react/displayname) doesn't work


Henry Potatoes

I wonder if eslint reactive rules are useful (react/display-name)to anyone ?

Currently in my code it doesn't show any warning if I don't put displayName. I expected that if I didn't put it, displayNameit would issue an eslint warning message.

E.g

Component.jsx

import React from 'react';

const Component = () => {
 return (
  <h1>Hello World</h1>
 );
};

export default Component;

.eslintrc

{
 . . .
 "rules": {
  "react/display-name": [2],
 }
 . . .
}

I expected there should be a lint warning, but nothing happened.

Is there a configuration I'm missing?

Twig

This rule will only show an error if your component doesn't have a name. In your case, the name of the component is Component. This is because react automatically translates the name of the component.

If you don't want the name to be translated automatically , you need to use the name with translation disabled . Then you will get the desired behavior."react/display-name": [2, { "ignoreTranspilerName": true }],

If your component looks like this, the currently configured rule will throw an error:

const Hello = createReactClass({
  render: function() {
    return <div>Hello {this.props.name}</div>;
  }
});
module.exports = Hello;

Related


react onScroll doesn't work

modern I am trying to add an onscroll event handler to a specific dom element. See the code below: class ScrollingApp extends React.Component { ... _handleScroll(ev) { console.log("Scrolling!"); } componentDidMount() { this.refs

React animation doesn't work

Bcherny I have a class Notificationfor managing create/delete notifications from UI . I can successfully show/hide the notification, but the notification doesn't show/hide during the animation. import React from 'react' import addons from 'react/addons' const

react - zIndex doesn't work

Sirisak My React App with autocomplete is not finished yet. Please help to validate my code. For the following code, I add search box with className autocomplete style. When I type it shows that the autocomplete does not overlap the tables. I tried adding z-in

React radio doesn't work

That I write a component of radios, when I make 3 radios, the value of radio1 is 1, the value of radio2 is 2, the value of radio2 is 3, then when I click on radio1, console.log(this.state.value)nothing is returned, when When I click on radio 2, it console.log(

React binding doesn't work

Will Dove React newbie needs help here. Here is a simple practice application that iterates over an array to output voting cards. I'm getting the dreaded 'Uncaught TypeError: Cannot read property 'add' of undefined' error, but as you can see from my code, I've

React bubbling doesn't work

Surrealism I have a child component and a parent component and I am trying to bubble some data from child component to parent component like this child: bubbleUp(data){ alert(data); this.props.addToLib(data); } ... render() { let formattedDate = this.pro

"react" doesn't work globally

Sviat Kuzhelev I can't figure out what I'm doing wrong. I've also read some questions about SOF, but none of them worked for me. I have a bunch of errors: Line 3: "React" must be in scope when using JSX react/react-in-jsx-scope Line 4: "React" must be in scope

React function doesn't work

Gaurav Chaudary I am trying to get the radio button value in server.R and after getting the value I want to perform some filtering based on the selected value of the radio button. code show as below: User Interface library(shiny) library(shinydashboard) librar

React syntax doesn't work

Zheng Jie componentDidMount() { const restaurants = Restaurant.all() restaurants.then( rests => { this.setState({ restaurants: rests }) }) } render() { const { restaurants } = this.state; return (

react onScroll doesn't work

modern I am trying to add an onscroll event handler to a specific dom element. See the code below: class ScrollingApp extends React.Component { ... _handleScroll(ev) { console.log("Scrolling!"); } componentDidMount() { this.refs

react - zIndex doesn't work

Sirisak My React App with autocomplete is not finished yet. Please help to validate my code. For the following code, I add search box with className autocomplete style. When I type it shows that the autocomplete does not overlap the tables. I tried adding z-in

React animation doesn't work

Bcherny I have a class Notificationfor managing create/delete notifications from UI . I can successfully show/hide the notification, but the notification doesn't show/hide during the animation. import React from 'react' import addons from 'react/addons' const

React animation doesn't work

Bcherny I have a class Notificationfor managing create/delete notifications from UI . I can successfully show/hide the notification, but the notification doesn't show/hide during the animation. import React from 'react' import addons from 'react/addons' const

react onScroll doesn't work

modern I am trying to add an onscroll event handler to a specific dom element. See the code below: class ScrollingApp extends React.Component { ... _handleScroll(ev) { console.log("Scrolling!"); } componentDidMount() { this.refs

react onScroll doesn't work

modern I am trying to add an onscroll event handler to a specific dom element. See the code below: class ScrollingApp extends React.Component { ... _handleScroll(ev) { console.log("Scrolling!"); } componentDidMount() { this.refs

react - zIndex doesn't work

Sirisak My React App with autocomplete is not finished yet. Please help to validate my code. For the following code, I add search box with className autocomplete style. When I type it shows that the autocomplete does not overlap the tables. I tried adding z-in

Stylus doesn't work with React

Stephen Bejide I'm helping create a web app and we've recently switched to stylus and react. I have rewritten all stylus lang files and wrote some react but react is not being styled at all. Here are the components below. import React, { Component } from 'reac

React doesn't work with Bootstrap

username I'm starting a new project using Flask + React + Bootstrap, but for some reason Bootstrap in JSX is not working. I am using gulp-react to convert JSX to JS. Here's the JSX (literally an example of a bootstrap site): var Example = React.createClass({

react ESLint(react/displayname) doesn't work

Henry Potatoes I wonder if eslint reactive rules are useful (react/display-name)to anyone ? Currently in my code it doesn't show any warning if I don't put displayName. I expected that if I didn't put it, displayNameit would issue an eslint warning message. E.

react ESLint(react/displayname) doesn't work

Henry Potatoes I wonder if eslint reactive rules are useful (react/display-name)to anyone ? Currently in my code it doesn't show any warning if I don't put displayName. I expected that if I didn't put it, displayNameit would issue an eslint warning message. E.

Object doesn't work as React child in React

Bennett I've read some answers on SO but no one seems to come across what I need. I have a function: const geoDataRTB = () => { return data.map((result) => result.request.buyerContext.request.geoData); }; It returns a json object. "geoData": {

react ESLint(react/displayname) doesn't work

Henry Potatoes I wonder if eslint reactive rules are useful (react/display-name)to anyone ? Currently in my code it doesn't show any warning if I don't put displayName. I expected that if I didn't put it, displayNameit would issue an eslint warning message. E.

react ESLint(react/displayname) doesn't work

Henry Potatoes I wonder if eslint reactive rules are useful (react/display-name)to anyone ? Currently in my code it doesn't show any warning if I don't put displayName. I expected that if I didn't put it, displayNameit would issue an eslint warning message. E.

react ESLint(react/displayname) doesn't work

Henry Potatoes I wonder if eslint reactive rules are useful (react/display-name)to anyone ? Currently in my code it doesn't show any warning if I don't put displayName. I expected that if I didn't put it, displayNameit would issue an eslint warning message. E.

react ESLint(react/displayname) doesn't work

Henry Potatoes I wonder if eslint reactive rules are useful (react/display-name)to anyone ? Currently in my code it doesn't show any warning if I don't put displayName. I expected that if I didn't put it, displayNameit would issue an eslint warning message. E.

Lodash's debounce doesn't work in React

user818700: Better to have a look at my code first: import React, { Component } from 'react'; import _ from 'lodash'; import Services from 'Services'; // Webservice calls export default class componentName extends Component { constructor(props) { super(

Why doesn't React Router work with <Switch>?

thinkvantagedu: I'm learning React Router and trying to build a basic app like this Home.js: import React from 'react'; import About from '../pages/About'; import { HashRouter as Router, Switch, Route, Link } from "react-router-dom"; const Navbar = () => {

"toHaveStyle" doesn't work on Jest (react typescript)

foreign 92 I would like to understand (and pass the test) why every time I try to use "toHaveStyle" I get the following reply: "The value received must be an HTMLElement or SVGElement. Type received is: object Value received: {}" . I am using React with Typesc

"toHaveStyle" doesn't work on Jest (react typescript)

foreign 92 I would like to understand (and pass the test) why every time I try to use "toHaveStyle" I get the following reply: "The value received must be an HTMLElement or SVGElement. Type received is: object Value received: {}" . I am using React with Typesc