npm install --save-dev babel-plugin-react-add-data-id
class Example extends React.Component{
render(){
return (
<MyComponent>
component
</MyComponent>
)
}
}
class Example extends React.Component{
render(){
return (
<MyComponent data-id="node-1">
component
</MyComponent>
)
}
}
{
"plugins": ["react-add-data-id"],
"presets": ["react","env"]
}
'module': {
'loaders': [{
'loader': 'babel-loader',
'test': /\.js$/,
'exclude': /node_modules/,
'query': {
'plugins': ['react-add-data-id'],
...
}
}]
}