score:1

Accepted answer

no, you can't. you can't have mycomp component and add an attribute to div element without passing a prop or even a ref.

in those scenarios, you should add another wrapper element and apply those attributes to it.

export default function wrapper({children}) {
  return (
    <div data-value="5">
      {children}
    </div>
  );
}

<wrapper>
  <mycomp/>
</wrapper>

Related Query

More Query from same tag