Lynn Chin
Lynn Chin

Reputation: 41

React-Select, how to include the styles css file?

I am trying to use the react-select component (https://github.com/JedWatson/react-select) and confused with this sentence while reading the documentation, see below:

Be sure to include styles at some point, probably during your bootstrapping
import 'react-select/dist/react-select.css';

When I import this line in the React JSX file where I am using the Select component I am getting the following error:

 ...node_modules/react-select/dist/react-select.css:8\n.Select 
    {\n^\nParseError: Unexpected token\n>",
    "traces": {
    "Application Trace": [
    {
      "id": 39,
    "trace": "app/views/layouts/application.html.erb:7:in 

 `_app_views_layouts_application_html_erb___377503645297909977_70313107001300'"
}
],
"Framework Trace": [
{
"id": 0,
"trace": "browserify-rails (3.3.0) lib/browserify-rails/browserify_processor.rb:220:in `run_browserify'"
},
{
"id": 1,
"trace": "browserify-rails (3.3.0) lib/browserify-rails/browserify_processor.rb:51:in `call'"
},
{
....
}

Can someone provide some hints on this issue?

Upvotes: 2

Views: 2691

Answers (1)

Lynn Chin
Lynn Chin

Reputation: 41

It looks like I found an answer towards this question.

Basically what I did is I manually copy the css file from node_modules/react-select/dist/react-select.css into /assets/javascript/stylesheets folder in my rails project.

For more infomation please look into: https://stackoverflow.com/a/10291177/5761338

Upvotes: 2

Related Questions