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.

Sign Up for Our Newsletters

Get only the best articles delivered to your mail

You May Also Like

React convert JSON to CSV

React convert JSON to CSV using JSONToCSVConvertor function. Suppose you have a table (GUI react table tool) and you want to export it into excel, then this function will come…
View Post

How to check react version?

Table of Contents Hide Check react version through command lineCheck version programmaticallyLive DemoRelated Posts: It is important to know how to check react version in order to keep the libraries…
View Post