Skip to content

Emitted event from the child cannot be caught #38

@ridan

Description

@ridan

I have been trying to follow the instructions. Currently I have something like this

export default function SimpleComp(props) {
  let name = props.name;
  const onButtonClick = props.onButtonClick;
  return (
    <div>
      hello all, the name is {name}
      <button onClick={onButtonClick}>Click this</button>
    </div>
  );
}

register(SimpleComp, 'simple-component', [
  'name'
  ],
  {
    onButtonClick: e => {
      console.log(e)
      e.stopPropagation();
      return new Event('clickbutton', { bubbles: true })
    }
  }
)

Now in my app.js I use it like this
<simple-component name='webcomponent' onButtonClick="console.log('attribute callback 'onclickbutton' triggered', this)"> </simple-component>

The component shows up fine but when trying to emit an event the eventemitter on the register function works but the function on the parent does not run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions