percy icon indicating copy to clipboard operation
percy copied to clipboard

Allow Support for multiple parameters in `JSX` syntax

Open AkinAguda opened this issue 2 years ago • 4 comments

The Problem

  • An error is thrown whenever I try to use pass in more than 1 argument to a "component" using the <Component /> syntax. Screenshot 2022-06-18 at 11 02 54

  • This is the component Screenshot 2022-06-18 at 11 02 37

  • This is the error thrown Screenshot 2022-06-18 at 11 11 11

  • The only alternative is to render the component like this: Screenshot 2022-06-18 at 11 12 28

Suggestion

It would be nice if we could allow support for multiple arguments in the JSX syntax as well

<Range
  min={1}
  max={10}
 />

Or let me know if there is a particular reason for this. Thanks

AkinAguda avatar Jun 18 '22 10:06 AkinAguda

I was actually planning to remove support for <Component field1={..} field2={..} /> syntax.

I'm trying to, as much as possible, only have one way to do things.

And only in cases where it's very convenient would we add a shortcut / additional way.

Curious about your thoughts, if any?

chinedufn avatar Jun 25 '22 11:06 chinedufn

Oh I see. I'd suggest to keep the <Component field1={..} field2={..} /> syntax in. This is especially nice to use when using it among other html elements (It fits in nicely). As opposed to writing a function call that return html!

Honestly, I can't think of any reason but it's syntactical advantages. It's more friendly for web developers as well since its pretty much a convention used in other popular web frameworks.

Also, does that mean are you removing Structs as components? @chinedufn

AkinAguda avatar Jun 25 '22 12:06 AkinAguda

Definitely keeping the View trait, so structs as components are here to stay.

As for the shorthand syntax.. Ok let's continue to support it for now. I'm not so sure about my own stance yet.

Also, just for context, the feature was introduced here https://github.com/chinedufn/percy/pull/139


Cool.. we can support this.. at least for the time being until we get feedback from others

chinedufn avatar Jun 25 '22 13:06 chinedufn

Awesome!

AkinAguda avatar Jun 25 '22 13:06 AkinAguda