Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using aria attributes on elements in react

I have the following render method:

render: function () {
  return (
    React.createElement('div', {className: 'modal', id: 'errorModal', tabIndex: '-1', role: 'dialog', ariaHidden: 'true', dataBackdrop: 'false', style: {marginTop: '30px'}}, 'text')
  )
}

That gives me error:

react.js:20541 Warning: Unknown props ariaHidden, dataBackdrop on tag. Remove these props from the element. For details, see in div (created by Constructor) in Constructor

How could I solve this? Documentation says that I can use these attributes. Lowercase does not work either. I don't want to use jsx.

like image 507
user99999 Avatar asked Feb 06 '23 08:02

user99999


1 Answers

Instead of camel case, use hyphens to define aria attributes as described in React's docs:

render: function () {
  return (
    React.createElement('div', {className: 'modal', id: 'errorModal', tabIndex: '-1', role: 'dialog', 'aria-hidden': 'true', dataBackdrop: 'false', style: {marginTop: '30px'}}, 'text')
  )
}
like image 117
TimoStaudinger Avatar answered Feb 08 '23 22:02

TimoStaudinger