react-contexify icon indicating copy to clipboard operation
react-contexify copied to clipboard

Getting warning about triggerEvent and propsFromTrigger

Open bardaxx opened this issue 4 years ago • 9 comments

Do you want to request a feature or report a bug? Bug

What is the current behavior?

I'm getting "React does not recognize the triggerEvent prop on a DOM element." or react_devtools_backend.js:2557 Warning: React does not recognize the propsFromTrigger prop on a DOM element.

What is the expected behavior? No warnings

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? "react": "17.0.2". Never used other versions

bardaxx avatar May 13 '21 08:05 bardaxx

Warning: React does not recognize the triggerEvent prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase triggerevent instead. If you accidentally passed it from a parent component, remove it from the DOM element.

Warning: React does not recognize the propsFromTrigger prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase propsfromtrigger instead. If you accidentally passed it from a parent component, remove it from the DOM element.

any help?

bardaxx avatar May 19 '21 09:05 bardaxx

without a reproduction I cannot help :(

fkhadra avatar Nov 03 '22 19:11 fkhadra

Hello. Did you solve this problem, I also encountered the same problem

jackzang98 avatar Apr 27 '23 03:04 jackzang98

Hello. Did you solve this problem, I also encountered the same problem

Nope, used this lib on another project and I got the same issue :\

bardaxx avatar Jun 12 '23 13:06 bardaxx

Same issue. It seems the warning thrown from <Menu/> component here

mrdulin avatar Dec 27 '23 08:12 mrdulin

This happens to me also in

  • win 10
  • react 18.2.0
  • react-contexify": "^6.0.0

This happens when useEffect is used to set the content of the menu.

EDIT: I solved this by making sure the content is inside Item tags. I for example added a spinner component inside div to menu and when ready the actual items wrapped inside <div></div>. This works but it produces this error. So I had like this:

export function ContextMenu(props: ContextMenuProps) {
  const [content, setContent] = useState<ReactNode | undefined>(undefined);
  const someStatus = useSelector(selectSomeStatus);
  useEffect(() => {
    if (someStatus === 'pending') {
      setContent(
        <div className='d-flex justify-content-center'><SomeSpinner/></div>);
    } else {
      const items = getMenuItems().
        map(item => <Item key={item.key} onClick={() => item.action()}>{item.key}</Item>);
      setContent(<div>{items}</div>);
    }
  }, [someStatus]);

  return (
    <Menu id={props.menuId}>
      {content}
    </Menu>
  );
}

When I removed the divs in BOTH cases I got rid of the error:

  useEffect(() => {
    if (someStatus === 'pending') {
      setContent(
        <Item className='d-flex justify-content-center'><SomeSpinner/></Item>);
    } else {
      const items = getMenuItems().
        map(item => <Item key={item.key} onClick={() => item.action()}>{item.key}</Item>);
      setContent(items);
    }
  }, [someStatus]);

char-m avatar Jan 21 '24 06:01 char-m

Just wrap your content in empty tags like so: <>your content...</>

ROTGP avatar Feb 21 '24 12:02 ROTGP