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.

Can't normal recognize using flow props in static methods

See original GitHub issue

Get error from [eslint] 'navigation' PropType is defined but prop is never used (react/no-unused-prop-types) when declaring prop types via flow in static methods, but I used this variable in static method code.

import type { NavigationScreenProp } from 'react-navigation';

export default class ComponentName extends Component<{}> {
  static navigationOptions = ({ navigation }: { navigation: NavigationScreenProp }) => ({ // error here
    headerLeft: (<NavigationBtn onPress={() => navigation.goBack()} />),
})
//... other code here
}

Have this plugins in .eslintrc "plugins": ["react", "react-native", "flowtype", "flow"],

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ljharbcommented, Apr 28, 2018

ahh i think i see the issue - you’re using render props, which are functions that return jsx, thus this plugin is considering them components.

0reactions
ljharbcommented, Feb 6, 2022

I’m going to assume that our component detection has improved to the point where this is no longer a problem. If that’s incorrect, please file a new issue with a repro.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't normal recognize using flow props in static methods
The real issue is that you're passing the entire props object around, which is both an antipattern and impossible to lint properly. If...
Read more >
Static Methods and Properties - L3HarrisGeospatial.com
This statement executes the Calculate class method on the MyClass class, passing in two arguments a and b, as well as a keyword...
Read more >
Static properties and methods
Usually, static methods are used to implement functions that belong to the class as a whole, but not to any particular object of...
Read more >
Static and Instance Methods, Variables, and Initialization Code
Before an object of a class is created, all static member variables in a class are initialized, and all static initialization code blocks...
Read more >
Why can't I define a static method in a Java interface?
Java 8 permits static interface methods. With Java 8, interfaces can have static methods. They can also have concrete instance methods, but not...
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