Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-toolbox how to include the styles correctly

I am trying to use the date picker from react-toolbox.

Here is my webpack config:

    {
        test: /\.css$/,
        loader: ExtractTextPlugin.extract('style-loader', 'css-loader!cssnext-loader')
    },{
        test: /\.scss$/,
        loaders: ['style', 'css', 'sass']
    }

I have .scss in the resolve section:

resolve: {
    extensions: ['', '.js', '.jsx', '.scss']
},

I have also wrapped my App component within ToolboxAPP

ReactDOM.render(
    <ToolboxApp>
        <Provider store={store}>
            <App />
        </Provider>
    </ToolboxApp>
, document.getElementById('root'))

When I rendered the component, here is what it looks like:

enter image description here

You can see from the image that the component is not styled, and the corresponding css class names are undefined.

Does anybody know what i did wrong?

like image 577
Cheng Avatar asked Aug 07 '26 22:08

Cheng


1 Answers

You need to include modules (which unfortunately may break any other styling not using modules).

See https://github.com/react-toolbox/react-toolbox/issues/121 for more info.

This is the line you will need to utilize in your webpack loader:

require.resolve('css-loader') + '?sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]',
like image 116
mattgi Avatar answered Aug 10 '26 12:08

mattgi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!