Component definition is missing display name – React Native Error

Total
0
Shares

React native throws error component definition is missing display name, when an anonymous function is exported. This is a ESLint warning because although you can work with anonymous functions, it is hard for React-console to list them in tree. Since they don’t have any display name, they are listed as <unknown> node, which is confusing.

The warning/error is generated due to situations like this –

export default () => {
  return (
    <View></View>
  )
}

Of course, you can use this component in your project but its best to provide a name to it for debugging and other purpose.

Code could be used like this –

export default SomeDisplayName () => {
  return (
    <View></View>
  )
}

    Tweet this to help others

This will solve your problem of component definition missing display name.