React component type.name is some abstract letters

Viewed 252

In my app i need to know children.type.name. In my test project i get what i expect

const TestChild2 = () => <td>b</td>;

Chrome dev tools

but in my "production" project it is just "n" or "Ez" or some other random letters.

import React from 'react'

const InputCell = (props) => {

    console.log('hi');
    return <td>hi</td>;
}

export default InputCell;

Chrome dev tools 2

Why does that happen? I use the same version of browser and same version of react ("react": "^16.13.1")in both projects.

1 Answers

Why does that happen?

This happens because React does this when building the production build. React probably does this to minify the code.

As workaround you can access the name in prod build as well by passing the name as prop/defaultProp.

Related