Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work for imported anonymous stateless functional components #11

Closed
imbhargav5 opened this issue Dec 6, 2015 · 10 comments
Closed

Comments

@imbhargav5
Copy link

https://facebook.github.io/react/blog/2015/10/07/react-v0.14.html

For components created using pure functions, the response is 'function(props) ....'.

@vvo
Copy link
Contributor

vvo commented Dec 8, 2015

Hi @bhargav175 do you think you can add a failing test case and submit a PR? Would be AWE-SOME

@imbhargav5
Copy link
Author

Sure, will give it a shot.

On Tue, 8 Dec 2015 at 16:31 Vincent Voyer notifications@github.com wrote:

Hi @bhargav175 https://github.com/bhargav175 do you think you can add a
failing test case and submit a PR? Would be AWE-SOME


Reply to this email directly or view it on GitHub
#11 (comment)
.

@imbhargav5
Copy link
Author

Doesn't work

 export default function(props){...}

Works

 export default function Flexbox(props){ ... } 

@vvo
Copy link
Contributor

vvo commented Dec 9, 2015

I think there's no way to do what you want: the anonymous function has no function.name so we cannot render it to a string since we do not know the function name.

if you console.log(<AnonymousStatelessComponent/>) you will see that JSX did not find any name for the component so we cannot stringify it.

Is that clear? Do you have another idea?

@vvo
Copy link
Contributor

vvo commented Dec 9, 2015

I have reworked the PR, see the master

@vvo
Copy link
Contributor

vvo commented Dec 10, 2015

What we could do here is turn any anonymous component to render into a string like and then compare them. The comparison will work if you compare anonymous component.

What do you think?

@imbhargav5
Copy link
Author

Will it work? Like you said, I dont see any property of that we could use to figure out the name.

@vvo
Copy link
Contributor

vvo commented Dec 10, 2015

Also @bhargav175 I would advise you to always use named components because when you use react-dev-tool you will have the same issue as this module.

I will update it to make it work because it's an easy fix but please use named components

@vvo
Copy link
Contributor

vvo commented Dec 10, 2015

Will it work?

Yes

@imbhargav5
Copy link
Author

Sure. Thanks @vvo .

@imbhargav5 imbhargav5 changed the title Does not work for stateless functional components Does not work for anonymous stateless functional components Dec 10, 2015
@imbhargav5 imbhargav5 changed the title Does not work for anonymous stateless functional components Does not work for imported anonymous stateless functional components Dec 10, 2015
@vvo vvo closed this as completed in dc0f65c Dec 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants