wyze / babel-plugin-transform-react-stateless-component-name

Adds a display name to the stateless component in the React Dev Tools.
MIT License
32 stars 8 forks source link

Ignore JSX Expression blocks #7

Closed dagjaneiro closed 7 years ago

dagjaneiro commented 7 years ago

We should ignore JSX elements rendered inside expression blocks since they do not represent individual components.

Previously the following example would add the displayName property to the content element:

import React from 'react'

const HelloWorld = () => {
  const content = (
    <div>
      {
        [1, 2, 3].map((n) => { return <h1>{n}</h1> })
      }
    </div>
  )

  return <div>{content}</div>
}

export default HelloWorld

This would throw a runtime error since content is a react element and cannot be extended with other properties.

codecov[bot] commented 7 years ago

Codecov Report

Merging #7 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master     #7   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           1      1           
  Lines          28     30    +2     
=====================================
+ Hits           28     30    +2
Impacted Files Coverage Δ
src/index.js 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 12dbbf9...eccc50c. Read the comment docs.

codecov[bot] commented 7 years ago

Codecov Report

Merging #7 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master     #7   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           1      1           
  Lines          28     30    +2     
=====================================
+ Hits           28     30    +2
Impacted Files Coverage Δ
src/index.js 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 12dbbf9...eccc50c. Read the comment docs.

wyze commented 7 years ago

Thanks, this looks really good!