2

I'm having a litte problem while creating a dropdown menu with bootstrap, in document https://facebook.github.io/react/docs/tags-and-attributes.html has said React supports all data-* and aria-* attributes as well as every attribute in the following lists, all attributes are camel-cased...

EX:

React.DOM.div(
   {
      className: 'dropdown', // available
      dataToggle: 'dropdown', // not available
      ariaExpanded: true // not available
   }
)

when run, attribute data-* and aria-* same not available?? i don't know why so???What could I do?

Thanks in advance.

2 Answers 2

1

Short Answer: just use normally as

data-toggle: 'dropdown'

According to React Docs:

All DOM properties and attributes (including event handlers) should be camelCased to be consistent with standard JavaScript style. We intentionally break with the spec here since the spec is inconsistent. However, data-* and aria-* attributes conform to the specs and should be lower-cased only.

You can look it at here

I've added a quick JSFiddle that make use of data attributes with JSX. I know it was quite messy (it was the best I come up with shorted amount of time).But you can see the use of data attribute with react in action.

Sign up to request clarification or add additional context in comments.

Comments

0

Try using it as follows:

React.DOM.div(
{
  className: 'dropdown',
  'data-toggle': 'dropdown',
  'aria-expanded': true
})

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.