opened
kirill-konshin
username_0
Add ability to flatten all children, not just fragments
issue
created
gregberge
username_1
Hello @username_0, I am sorry but what is the use-case? I am curious!
comment
created
kirill-konshin
username_0
I was making a gatsby plug-in, to wrap some MDX images, so I need to create a wrapper that would grab transformed react elements and extract some of their props to process them. The problem is markup may change so easiest way is to flatten all children and just filter them.
comment
closed
gregberge
username_1
issue
created
gregberge
username_1
I think it is a very specific use-case. You should just copy the code of this repository in your project. I don't think it worth it to include it here and penalize every one (package size) for this use-case.
comment
created
kirill-konshin
username_0
I've added 62 symbols.

The proposed functionality fits perfectly as you already recursively flatten the children, all I added is a flag to do this for all elements, not just fragments.
comment
created
gregberge
username_1
I am sorry this is not a main "use-case", if someone asks again for it I will consider it.
comment
created
kirill-konshin
username_0
Although I do understand that it's not a main use case, someone has already asked — me.

Addition perfectly fits in library name "react-flatten-children" — it produces flat array of all children.

I don't see any problems here, and reasons not to include... maintenance burden is not high. I can add tests if needed.
comment
created
gregberge
username_1
@username_0 your use-case is very very specific. You lose information by stripping components. The goal of this library is a "flattening", in a flattening, nothing is lost, it is just flattened. Your use-case is completely different! Anyway, I don't understand, what is the problem to just copy a small script in your code?
comment
created
kirill-konshin
username_0
That’s exactly what I did, I copied. Anyway, I see you’re not willing to cooperate, so I’m done here.
comment