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 Native background color

In React Native background color can be applied using background-color css property. The only difference is that we need to use camel case as backgroundColor. Check out the code –…
View Post

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