Skip to content

Can we reuse React components with properties as Web Components with attributes without doing any extra work? #171

Open
@AndyObtiva

Description

@AndyObtiva

I'm trying to understand something from the README, which seems to tell me I have to do extra work to expose React components as Web Components when using properties.

In this example:

<web-greeting name="Justin"></web-greeting>

Is there a way to actually hit the ground running with this by being able to forward any attributes to React automatically?

I have about 100 React components and I really don't want to add this code:

const WebGreeting = r2wc(Greeting, {
  props: {
    name: "string",
  },

The whole purpose of computer software is automation, and if I have to do that work manually, it's a waste of time.

I think if that is not supported automatically, you should support it by forwarding any data attributes under the property namespace automatically like this:

<web-greeting data-property-name="Justin" data-property-dob="2004-01-17" data-property-id="93292"></web-greeting>

Alternatively, forward property-* attributes instead if possible given it would be shorter syntax:

<web-greeting property-name="Justin" property-dob="2004-01-17" property-id="93292"></web-greeting>

Without support for that, this library is near useless to me, but I really need a library like this to enable using React components as Web Components.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions