score:1
you can't do that because attribute without any value means that this attribute has value true
in jsx. just don't pass data-test
and this.props['data-test']
will be undefined in your component. or if you need to have this attribute with empty value then just add it to your default values in component definition.
defaultprops: {
'data-test': ''
}
score:2
if you refer to the doc on createelement api, you can insert the value to your data-test prop like this:
react.createelement('div', {classname: 'test', 'data-test': 'some value'});
Source: stackoverflow.com
Related Query
- How to add data attribute without value in react create element?
- how to add attribute without actually editing the HTML element in react
- How can i create a new element and add onclick attribute to it using dom Manipulation in react
- React JS - How to add value from state to specific element
- How do I add WebPack polyfill to React App created with React Create App without ejecting?
- how to create React Context for a function value without re-rendering all the time
- How can I prevent to add data if the object property value is different using react js
- How create React Typescript component with required and optional values but required value without default value?
- How can I add an element to a list with a key value using a useState Record type in React typescript?
- How to fetch a data without using useffect or setTimeout and add loader in react hooks
- How to create new element and render data each time the data is fetched in react
- How to add attribute name and attribute value dynamically in React
- How do I get an attribute of an element nested in a React component using Jest and/or Enzyme?
- How to add additional props to a React element passed in as a prop?
- How to cache fetched data in react without redux
- How to add style to React Element if it's created this way?
- How to add a comma in array.map after every element except last element in React JSX
- How to add new elements without re-rendering whole list with React
- How to add class in element on scroll React js
- How to add a data attribute to Material-UI Button?
- How to add a new key value to react js state array?
- How to create a React App without Create-react-app
- In React how to add key prop to element passed as Object
- How to create react app without git (skipping git)?
- How do I add a custom font to my Card Element when using React Stripe Elements?
- How to conditionally add attributes to react DOM element
- How to pass percentage value to width to React data grid column
- How can mock the value of a state and data in my react test
- How to add a CSS class to an element on click - React
- How to fetch data without useEffect hooks in React function component?
More Query from same tag
- Call Firebase HTTPS callable cloud functions in React
- react js hooks useEffect infinite loop
- VSCode does not format JSX Correctly
- How to get each item's value in React.js
- Accessing context from useEffect
- React Custom Hook Behind the scene
- Storybook: Can you give decorators, parameters and hooks to Templates?
- Access to a several elements through one ref React
- AWS AppSync + React-Apollo Query/useQuery raising exception this.currentObservable.query.getCurrentResult is not a function
- How to fetch api when mounting of React.js
- import React Components to HTML
- Can't access params sent in POST request from React client to Rails api
- Issues with open PDF files from my server
- How to implement Redux Slicer
- How to re-render a react component with an input value passed from another component
- React, dynamically add text to ref span
- React webpack bundle not utf-8
- ReactJS - Can't import component
- How to restrict date selection in React native ios/android datepicker
- How to change CSS of columns - ReactTable
- Change react-icon color when hover not working properly
- EsLint rule for label
- Google app-engine deploy all my react file even sources
- Conditinal style class in reactjs
- Checking React defaultProps with Flow
- React adding !important seems to break component re-rendering
- Unit Testing functions to check dispatch to be called
- Correctly push element to array state with async function
- How to clear a Material UI textfield of file type
- Await async firebase foreach?