css - Webpack 2 duplicate declaration when redefine a style inside reactjs -
i error:
error in ./src/data/js/component/mdldropdown.jsx module build failed: d:/programming/src/data/js/component/mdldropdown.jsx: duplicate declaration "selectfield"
when use webpack 2 config:
const path = require('path'); const appcfg = require("./app.config.js"); var packg = require("./package.json"); var webpackuglifyjsplugin = require("webpack-uglify-js-plugin") //babel loader const babelloader = { test: /\.jsx$/, exclude: /node_modules/, include: [path.resolve(__dirname, "./src/data/js")], loader: 'babel-loader' }; let wp = { entry: { mainapp: appcfg.entrypointjs, //mainapp.bundle.js vendor: object.keys(packg.dependencies) //vendor.min.js }, output: { filename:"[name].bundle.js", path: path.resolve(__dirname, appcfg.outputdir) }, module: { rules:[ babelloader, { test: /\.css$/, use: ['style-loader', 'css-loader'], } ] }, resolve: { extensions: [".js", ".jsx"] }, /*, external module */ externals: { "react": "react", "react-dom": "reactdom", "jquery": "jquery" } };
when process follow source:
import react 'react'; import reactdom "react-dom"; import { selectfield, option } 'react-mdl-extra'; const selectfield = styled.selectfield``; //redefine width of original component /** ui component rapresents state component stateless */ export default class mdldropdown extends react.component { constructor(props) { super(props); this.state = {currentselection:""}; } /** init vars */ componentwillmount() { const { defaultvalue } = this.props; if(defaultvalue) this.setstate({currentselection:defaultvalue}); } render() { const { id,onchange,valuearray,displayarray,label } = this.props; const on_change = (v)=>{ this.setstate({currentselection:v}); if(onchange) onchange(v); }; //displayarray[idx] const map_option = ()=>{return valuearray.map((val,idx,ar)=>{ return <option value={val}>{displayarray[idx]}</option> })}; return ( <selectfield id={id} onchange={on_change} label={label} value={this.state.currentselection} > {map_option()} </selectfield> ); /* return ( <select id={id} ref="ddn" style={style} onchange={on_change} label={label} value={this.state.currentselection} > {map_option()} </select> ) */ } }
i want replace original css, because author of component set width in css (https://github.com/hribb/react-mdl-extra/blob/master/src/selectfield/selectfield.css).
i read example , i'd set width above error arise... when declare const selectfield
p.s. can read use react, material lite, babel
Comments
Post a Comment