2023-05-03 11:06:20 +02:00
|
|
|
== Why is this an issue?
|
|
|
|
|
2021-06-08 14:23:48 +02:00
|
|
|
This rule enforces the idea to use ES6 style to create React Component instead of the ES5 way.
|
|
|
|
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Noncompliant code example
|
2021-06-08 14:23:48 +02:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,javascript]
|
2021-06-08 14:23:48 +02:00
|
|
|
----
|
|
|
|
var Rating = createReactClass({ // Noncompliant
|
|
|
|
[...]
|
|
|
|
});
|
|
|
|
----
|
|
|
|
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Compliant solution
|
2021-06-08 14:23:48 +02:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,javascript]
|
2021-06-08 14:23:48 +02:00
|
|
|
----
|
|
|
|
export default class Rating extends React.Component { // Compliant
|
|
|
|
[...]
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
2021-06-08 15:52:13 +02:00
|
|
|
'''
|
2021-06-08 14:23:48 +02:00
|
|
|
== Comments And Links
|
|
|
|
(visible only on this page)
|
|
|
|
|
2023-05-25 14:18:12 +02:00
|
|
|
=== on 23 Feb 2018, 11:48:51 Alexandre Gigleux wrote:
|
|
|
|
Covered by ESLint for React: \https://github.com/yannickcr/eslint-plugin-react/blob/HEAD/docs/rules/prefer-es6-class.md (react/prefer-es6-class)
|
|
|
|
|
2021-06-08 14:23:48 +02:00
|
|
|
endif::env-github,rspecator-view[]
|