Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was another attempt to fix this (#338) which I suppose wasn't merged because the author didn't address an issue raised about calling function children in order to print them.
This is fine for pure functions that return react elements, but you can't guarantee that function children always behave like this, so this could cause problems for users who have unconventional function children.
Another approach could be printing the function's source, but since sources are subject to transpilation by babel before runtime, just printing the function's body wouldn't yield JSX.
Or you could use source maps to print the original code instead, but printing JSX code as string has its own limitations as the output isn't parsed and formatted by this library.
As each of these methods have their own trade-offs, I've decided to go for a less opinionated solution and leave this decision up to the library user. Functions as children will work the same as if they were any other prop, users can choose how to format them using
functionValue
andshowFunctions
options.Additionally, I've altered both these options to provide more granularity on if and how each function prints since users may want to handle render props differently than other function props.
What I did:
prop
param tofunctionValue
optionshowFunctions
function option to filter prop by prop