1

The errors I am getting are: bundle.js:1168 Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components). Check the render method of AddBillForm.

bundle.js:778 Uncaught Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of AddBillForm. I AM USING WEBPACK and ES6. Please try to provide a fiddle example with datepicker material UI

//MyButton.jsx

var React = require('react');
var RaisedButton =  require('material-ui/RaisedButton');
var MyButton = React.createClass({

    render: function()
    {

        return (
            <Link to={this.props.to}>{this.props.message}</Link>

        );
    }
});

module.exports = MyButton;

//AddBillForm.jsx (Here I am using MyButton component)

var React = require('react');
var ReactDOM = require('react-dom');

var MuiThemeProvider = require('material-ui/styles/MuiThemeProvider');
var GenericInputArea = require('../GenericInputArea');
var MyButton = require('../MyButton')

var AddBillForm=React.createClass({
    render: function()
    {
        return (
             <div className="row">
                <div className="col-md-12 col-sm-12 col-xs-12 biller-name">
                    <GenericInputArea placeholder="Enter your biller name" />
                </div>
                <div className="col-md-12 col-sm-12 col-xs-12 account-id">
                    <GenericInputArea placeholder="Enter 10 digit account Id" />
                    <p>What is my account id? Refer to sample bill below</p>
                </div>
                <MyButton  label = "testing"/>
            </div>
        );
    },
});

module.exports = AddBillForm;

//app.jsx

var React = require('react');
var ReactDOM = require('react-dom');
var {Route, Router, IndexRoute, hashHistory} = require('react-router');
var RaisedButton =  require('material-ui/RaisedButton');

var GetMyBillsMain = require('./components/getMyBills/GetMyBillsMain');
var AddBillMain = require('./components/addBillDetails/AddBillMain');
var AddBiller =  require('./components/selectBiller/AddBiller');
var BillDetailsMain = require('./components/billDetails/BillDetailsMain')

// Load foundation
require('style!css!bootstrap/dist/css/bootstrap.min.css')

// App css
require('style!css!bootstrapStyles')
require('style!css!customStyles')



ReactDOM.render(
        // <Main></Main>
        <Router history={hashHistory}>
            <Route path="/" component={GetMyBillsMain} />
            <Route path = "selectBiller" component = {AddBiller} />
            <Route path = "addBillDetails" component = {AddBillMain} />
            <Route path = "billDetails" component = {BillDetailsMain} />
        </Router>
        , 
    document.getElementById('main'));

//webpack.config.js (This is my webpack config)

var webpack = require('webpack');
var ExtractTextPlugin   = require("extract-text-webpack-plugin");


module.exports = {
    entry: [
    'script!jquery/dist/jquery.min.js',
    'script!bootstrap/dist/js/bootstrap.min.js', 
    './app/app.jsx'
    ],
    externals: {
        jquery: 'jQuery'
    },
    plugins: [
        new webpack.ProvidePlugin({
            '$': 'jquery',
            'jQuery': 'jquery'
        })
    ],
    output: {
        path: __dirname,
        filename: './public/bundle.js'
    },

    resolve: {
        root: __dirname,
        alias: {
            bootstrapStyles : 'bootstrap/dist/css/bootstrap.min.css',
            customStyles: 'app/styles/style.css'
        },

        extensions: ['', '.jsx', '.js' ]
    },
    module : {
        loaders: [
            {
                loader: 'babel-loader',
                query : {
                    presets: [
                        'react', 'es2015'
                    ]
                },
                test: /\.jsx?$/,
                exclude: /(node_modules| bower_components)/
            },
            {
                test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/, 
                loader: 'url?limit=10000&mimetype=application/font-woff'
              },
              {
                test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, 
                loader: 'url?limit=10000&mimetype=application/octet-stream'
              },
              {
                test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, 
                loader: 'file'
              },
              {
                test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, 
                loader: 'url?limit=10000&mimetype=image/svg+xml'
              }
        ]
    }
}

1 Answer 1

1

I had a similar problem and that was solved by changing the way I imported the material-ui components.

Try change

var MuiThemeProvider = require('material-ui/styles/MuiThemeProvider');
var RaisedButton =  require('material-ui/RaisedButton');

to

var {MuiThemeProvider} = require ('material-ui/styles');
var {RaisedButton} =  require('material-ui');

and all other material-ui components if you have any other.

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

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.