web-react-components icon indicating copy to clipboard operation
web-react-components copied to clipboard

Emitted event from the child cannot be caught

Open ridan opened this issue 5 years ago • 1 comments

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.

ridan avatar Jul 09 '19 13:07 ridan

I have the same bug, can't catch mouseenter/mouseleave events in react components, which wraps my "web-react-components"

Lukavyi avatar May 11 '20 09:05 Lukavyi