Expected 'this' to be used by class method 'render'
7import { SideBarFooter } from './SideBarFooter/SideBarFooter';
8
9class Sidebar extends Component {
10 render() {11 return (
12 <Menu borderless vertical stackable fixed="left" className="side-nav">
13 <SidebarItem name="home" label="Home" highlight />
Expected 'this' to be used by class method 'render'
5import Logo from '../../assets/images/logo.jpg';
6
7class HeaderNav extends Component {
8 render() { 9 return (
10 <Menu borderless className="top-menu" fixed="top">
11 <Menu.Item header className="logo">
Description
If a class method does not use this
, it can sometimes be made into a static function. If you do convert the method into a static function, instances of the class that call that particular method have to be converted to a static call as well (MyClass.callStaticMethod())
Bad Practice
class Person {
sayHi() {
const greeting = document.createElement("div");
greeting.innerText = "Hello!";
document.appendChild();
}
}
const person = new Person();
person.sayHi();
Recommended
class Person {
static sayHi() {
const greeting = document.createElement("div");
greeting.innerText = "Hello!";
document.appendChild();
}
}
Person.sayHi();