1

I would like my browser to show my React application with QuickTab component, in the style I assigned.

This is what my browser shows currently: Browser screenshot

CSS:

.MostPopular{
  width: 20%;
  height: 100px;
  background-color: #0000FF;
  border-radius: 0 0 30px 30px;
  margin: 2% auto;
  position: relative;
}

Here is the component. I left the other switch cases out for brevity.

React, QuickTab.js:

 import React, {Component} from 'react';
 import classes from './QuickTab.css';
 import PropTypes from 'prop-types';

class QuickTab extends Component{
  render(){
    let quickTab = null;

    switch(this.props.type){

      case('most-popular'):
        quickTab= <div className={classes.MostPopular}></div>
        break;

      default:
        quickTab= null;

    }

    return quickTab;
  }
}

//Add prop type validation
QuickTab.propTypes = {
  type: PropTypes.string.isRequired
};

export default QuickTab;

Here's the component call in my App.js file:

import React, { Component } from 'react';
import QuickTab from'../components/QuickTabGroup/QuickTab/QuickTab';

class App extends Component {
  render() {
    return (
      <QuickTab type='most-popular'/>
    );
  }
}

1 Answer 1

1

Replace className={classes.MostPopular} to className="MostPopular" and import your style like this

import './QuickTab.css';

or

require('./QuickTab.css');

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.