question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expected 'this' to be used by class method 'render'

See original GitHub issue

Hi, from what I’ve read this has already been fixed in the eslint-config-airbnb package but I’m getting this error. I’ve probably set up my .eslintrc file incorrectly or something so if anyone could point out my mistake I’d really appreciate it.

.eslintrc

{
    "extends": "airbnb/base",
    "parser": "babel-eslint",
    "parserOptions": {
        "sourceType": "module",
        "allowImportExportEverywhere": false,
        "ecmaFeatures": {
          "jsx": true,
        },
    },
    "plugins": [
        "react",
    ],
    "env": {
        "node": true,
        "jasmine": true,
    },
    "rules": {
        "id-length": 0,
        "indent": [1, 4],
        "jsx-quotes": 1,
        "no-console": 0,
        "no-unused-vars": [1, {"vars": "local", "args": "none"}],
        "react/forbid-prop-types": 1,
        "react/jsx-boolean-value": 1,
        "react/jsx-closing-bracket-location": 1,
        "react/jsx-curly-spacing": 1,
        "react/jsx-indent-props": 1,
        "react/jsx-key": 1,
        "react/jsx-max-props-per-line": 1,
        "react/jsx-no-duplicate-props": 1,
        "react/jsx-no-undef": 1,
        "react/jsx-sort-props": 1,
        "react/jsx-uses-react": 1,
        "react/jsx-uses-vars": 1,
        "react/no-danger": 1,
        "react/no-did-mount-set-state": 1,
        "react/no-did-update-set-state": 1,
        "react/no-direct-mutation-state": 1,
        "react/no-multi-comp": 1,
        "react/no-set-state": 1,
        "react/no-unknown-property": 1,
        "react/prefer-es6-class": 1,
        "react/prop-types": 1,
        "react/react-in-jsx-scope": 1,
        "react/require-extension": 1,
        "react/self-closing-comp": 1,
        "react/sort-comp": 1,
        "react/sort-prop-types": 1,
        "react/wrap-multilines": 1,
        "strict": 0,
    },
}

package.json

{
  "name": "KHTestApp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "@exponent/ex-navigation": "^2.1.5",
    "@exponent/vector-icons": "^2.0.3",
    "babel-eslint": "6",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-preset-react-native-stage-0": "^1.0.1",
    "exponent": "^12.0.0-rc.5",
    "react": "15.4.1",
    "react-native": "0.39.0",
    "react-native-code-push": "latest",
    "react-native-vector-icons": "^3.0.0"
  },
  "devDependencies": {
    "babel-jest": "17.0.2",
    "babel-preset-react-native": "1.9.0",
    "eslint": "^3.11.1",
    "eslint-config-airbnb": "^13.0.0",
    "eslint-plugin-import": "^2.2.0",
    "eslint-plugin-jsx-a11y": "^2.2.3",
    "eslint-plugin-react": "^6.8.0",
    "jest": "17.0.3",
    "react-test-renderer": "15.4.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
ljharbcommented, Dec 9, 2016

np, please reopen if it’s still a problem

1reaction
MyGuySicommented, Dec 9, 2016

@ljharb That’s great, thank you for all of that 😃

I’m still a noob so thank you all for helping out. I’ll try what you’ve suggested after the weekend

Read more comments on GitHub >

github_iconTop Results From Across the Web

Expected 'this' to be used by class method - Stack Overflow
you should bind the function to this as the ESLint error says "Expected 'this' to be used by class method 'getUrlParams'
Read more >
class-methods-use-this - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
expected 'this' to be used by class method - You.com
This is a ESlint rule, see class-methods-use-this. You could extract the method getUrlParams and put it into a helper, or to make it...
Read more >
[Solved]-Expected 'this' to be used by class method-Reactjs
This is a ESlint rule, see class-methods-use-this. You could extract the method getUrlParams and put it into a helper, or to make it...
Read more >
class-methods-use-this - Rules - ESLint - GitHub Pages
Enforce that class methods utilize this (class-methods-use-this) ... console.log("Hello World"); /*error Expected 'this' to be used by class method 'foo'.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found