Dropdown values not showing when I click dropdown button - Reactjs - reactjs

Dropdown values not showing in Address section. I used bootstrap 4 code.
I am not getting any error, when I am clicking dropdown it's not showing dropdown values.
I have added bootstrap 4 dropdown on this page but it's not working dropdown.
Please help with this.
Here is the code for review and I am a beginner at the react js. Please help
import React from 'react'
const ProfileInfo = () => {
return (
<div className="container-fluid">
<div className="row clearfix">
<div className="col-md-6 col-sm-12"> </div>
<div className="col-md-6 col-sm-12"> </div>
</div>
<div className="row clearfix">
<div className="col-md-6 col-sm-12">
<div className="card mb-3 shadow-sm p-3 bg-white rounded" >
<h5 className="card-title" style={{ color: '#009540' }}><strong>Profile: </strong> </h5>
<p className="card-text"><strong>Navn: </strong> Bengt Nilsfors</p>
<p className="card-text"><strong>Kontaktinformasjon: </strong> 95833897, nilsfors#gmail.com</p>
<div className="dropdown">
<button className="btn btn-info dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Address
</button>
<div className="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a className="dropdown-item" href="#">Address1</a>
<a className="dropdown-item" href="#">Address2</a>
</div>
</div><br/>
<p className="card-text"><strong>Adresse: </strong> Nøkken 7 H0101, 9016 Tromsø</p>
<p className="card-text"><strong>Passord: </strong> ***********</p>
<button className="btn btn-success">Rediger</button>
</div>
</div>
<div className="col-md-6 col-sm-12">
<div className="card mb-3 shadow-sm p-3 bg-white rounded" >
<h5 className="card-title" style={{ color: '#009540' }} ><strong>Nettverksanalyse</strong></h5>
<img className="card-img" variant="top" src="../images/testimg.png" style={{ width: '152px' }} />
<div style= {{ position: 'absolute', top: '66px', right: '108px' }}>17:58:55: Henter nettverskinfo...<br/>
18:00:31: Nettverkstatus ok. Ingen feil funnet.</div>
<button className="btn btn-warning mt-2 text-center">See details</button>
</div>
</div>
</div>
<div className="row">
<div className="col-md-4 mt-5 text-center">
<div className="card mb-3 shadow-sm p-3 bg-white rounded" >
<div className="card-body">
<h5 className="card-title" style={{ color: '#009540' }}>Abonnement</h5>
<p className="card-text"><strong>Internett</strong></p>
<p className="card-text">Giga (1000/1000) Kr 699,- per mnd.</p>
Oppgrader
</div>
</div>
</div>
<div className="col-md-4 mt-5 text-center">
<div className="card mb-3 shadow-sm p-3 bg-white rounded">
<div className="card-body">
<h5 className="card-title" style={{ color: '#009540' }}>Faktura</h5>
<ul className="list-group" style= {{ float: 'left' }}>
<li><a className="card-link" href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}>Mars 2021</a></li>
<li><a className="card-link" href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}>Desember 2020</a></li>
<li><a className="card-link"href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}>Februar 2021</a></li>
</ul><ul className="list-group" style={{ float: 'right' }}>
<li><a className="card-link" href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}>Desember 2020</a></li>
<li><a className="card-link" href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}> November 2020</a></li>
<li><a className="card-link" href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}>Oktober 2020</a></li>
</ul>
<div style={{ marginTop: '76px' }}> Se alle</div>
</div>
</div>
</div>
<div className="col-md-4 mt-5 text-center">
<div className="card mb-3 shadow-sm p-3 bg-white rounded">
<div className="card-body">
<h5 className="card-title" style={{ color: '#009540' }}>Kontakt oss</h5>
<p className="card-text">Kontakt oss via chat eller telefon 38 99 01 00.</p>
Chat
</div>
</div>
</div>
</div>
</div>
)
}
export default ProfileInfo

I think you need to use an html table. Then your code will look like this :
<button className="btn btn-info dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Address
</button>
<ul className="dropdown-menu" aria-labelledby="dropdownMenuButton">
<li><a className="dropdown-item" href="#">Address1</a></li>
<li><a className="dropdown-item" href="#">Address2</a></li>
</ul>
</div>
But with React you have a specific bootstrap components. You should use these components : https://react-bootstrap.github.io/components/dropdowns/

Related

How can I get pagination to end properly per category in React?

So I have a list of categories that is parsed into my page with specific images. I am trying to get a paginated page to have a limit. In my case it only has an end for all of the images, but not for the specific category those images fit into - essentially it will over extend to blank pages for the specific category you select. how can i provide my categorized images a limit?
import Pagination from 'react-js-pagination'
....
<Fragment>
<section id="contents" className="container mt-5">
<div className="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Categories
</button>
<ul className="dropdown-menu">
{categories.map(category => (
<li
style={{
cursor: 'pointer',
listStyleType: 'none'
}}
key={category}
onClick={() => setCategory(category)}
>
<a className='dropdown-item'>{category}</a>
</li>
))}
</ul>
</div>
<div className="row" id ='cards'>
<Fragment>
<div className="col-6 col-md-9" >
{category}
<div className="row" >
{contents && contents.map(content => (
<ContCard key={content._id} content={content} col={4} />
))}
</div>
</div>
</Fragment>
</div>
</section>
{resPerPage <= contentsCount && (
<div className="d-flex justify-content-center mt-5">
<Pagination
activePage={currentPage}
itemsCountPerPage={resPerPage}
totalItemsCount={contentsCount}
onChange={setCurrentPageNo}
nextPageText={'Next'}
prevPageText={'Prev'}
firstPageText={'First'}
lastPageText={'Last'}
itemClass="page-item"
linkClass="page-link"
/>
</div>
)}
</Fragment>

BootStrap 5 React Js 4 products in a row not getting displayed

I'm a beginner in React Js, and I'm using React Js with BootStrap 5.2.0
My product cards are not getting displayed in a row
I want to display 4 product cards in a row.
Adding Codes:
Home Page code:
<div className="container-fluid mb-2">
<Carousel />
<div className="mt-2">
<div className="row">
<div className="col-md-2">
<GetAllCategories />
</div>
<div className="col-md-10">
<div className="row row-cols-1 row-cols-md-4 g-4">
<div className="col">
{products.map((product) => {
return <ProductCard item={product} />;
})}
</div>
</div>
</div>
</div>
</div>
</div>
PRODUCT CARD CODE:
const ProductCard = (product) => {
return (
<div class="card border-color rounded-card card-hover product-card custom-bg">
<img
src={"http://localhost:8080/api/product/" + product.item.imageName}
class="card-img-top rounded mx-auto d-block m-2"
alt="img"
style={{
maxHeight: "270px",
maxWidth: "100%",
width: "auto",
}}
/>
<div class="card-body text-color">
<h5 class="card-title d-flex justify-content-between">
<div>
<b>{product.item.title}</b>
</div>
<CategoryNavigator
item={{
id: product.item.category.id,
title: product.item.category.title,
}}
/>
</h5>
<p className="card-text">
<b>{product.item.description}</b>
</p>
</div>
<div class="card-footer">
<div className="text-center text-color">
<p>
<span>
<h4>Price : ₹{product.item.price}</h4>
</span>
</p>
</div>
<div className="d-flex justify-content-between">
<Link
to={`/product/${product.item.id}/category/${product.item.category.id}`}
className="btn bg-color custom-bg-text"
>
Add to Cart
</Link>
<p class="text-color">
<b>
<i>Stock :</i> {product.item.quantity}
</b>
</p>
</div>
</div>
</div>
);
};
export default ProductCard;
From the past 4 days, I'm struggling to resolve this issue.
Please help me to fix this.
Thank You
You need to move <div className="col"> from home page to ProductCard as first element in return statement. Sample code at https://codesandbox.io/s/falling-thunder-swzukd

Display divs one above the other

import React from "react";
export default function Example() {
return (
<div>
<div
className="grid"
style={{
gridTemplateColumns: "1.75rem repeat(288, minmax(0, 1fr)) auto",
}}
>
<div
className="mt-px inline-grid grid-cols-1 sm:col-start-3"
style={{ gridColumn: "74 / span 12" }}
>
<a href="#" className="rounded-lg bg-blue-50 p-2 text-xs">
<p className="order-1 font-semibold text-blue-700">Breakfast</p>
<p className="text-blue-500 group-hover:text-blue-700">
<time dateTime="2022-01-12T06:00">6:00 AM</time>
</p>
</a>
</div>
<div
className="mt-px inline-grid grid-cols-1 sm:col-start-3"
style={{ gridColumn: "76 / span 12" }}
>
<a href="#" className="rounded-lg bg-blue-50 p-2 text-xs">
<p className="order-1 font-semibold text-blue-700">Breakfast</p>
<p className="text-blue-500 group-hover:text-blue-700">
<time dateTime="2022-01-12T06:00">6:30 AM</time>
</p>
</a>
</div>
</div>
</div>
);
}
If you want both the tiles over one another , add absolute w-1/4 right-4 class to both the divs.
import React from "react";
export default function Example() {
return (
<div>
<div
className="grid"
style={{
gridTemplateColumns: "1.75rem repeat(288, minmax(0, 1fr)) auto",
}}
>
<div
className="absolute w-1/4 right-4 mt-px inline-grid grid-cols-1 sm:col-start-3"
style={{ gridColumn: "74 / span 12" }}
>
<a href="#" className="rounded-lg bg-blue-50 p-2 text-xs">
<p className="order-1 font-semibold text-blue-700">Breakfast</p>
<p className="text-blue-500 group-hover:text-blue-700">
<time dateTime="2022-01-12T06:00">6:00 AM</time>
</p>
</a>
</div>
<div
className="absolute w-1/4 right-4 mt-px inline-grid grid-cols-1 sm:col-start-3"
style={{ gridColumn: "76 / span 12" }}
>
<a href="#" className="rounded-lg bg-blue-50 p-2 text-xs">
<p className="order-1 font-semibold text-blue-700">Breakfast</p>
<p className="text-blue-500 group-hover:text-blue-700">
<time dateTime="2022-01-12T06:00">6:30 AM</time>
</p>
</a>
</div>
</div>
</div>
);
}
you can adjust right and width as per your requirement .

media query not working int the below code - Recact js

In the below code the media query not working. Please help if any mistake I did.
I used paragraph media query the below. When I checked in mobile mode t is not working.
/* eslint-disable react/jsx-no-target-blank /
/ eslint-disable react/no-unescaped-entities */
import React from 'react'
import { DropdownButton, Dropdown } from 'react-bootstrap'
const ProfileInfo = () => {
const paragraph = {
position: 'absolute',
top: '66px',
right: '108px',
'#media screen and (min-width: 610px)': {
position: 'static'
}
}
return (
<div className="container-fluid">
<div className="row clearfix">
<div className="col-md-6 col-sm-12"> </div>
<div className="col-md-6 col-sm-12"> </div>
</div>
<div className="row" style={{ margin: 'auto', width: '50%' }}>
<div className="alert alert-success col-md-12 col-sm-12">
<h5 className="alert-heading">Aktive meldinger</h5>
<p>
Hahahahahhhhhfgdfgf gdfgdfgffgdfggfhgh fgdfgdfgfgfg
</p>
</div>
</div>
<div className="row clearfix">
<div className="col-md-6 col-sm-12">
<div className="card mb-3 shadow-sm p-3 bg-white rounded" >
<h5 className="card-title" style={{ color: '#009540' }}><strong>Profile: </strong> </h5>
<p className="card-text"><strong>Navn: </strong> Bengt Nilsfors</p>
<p className="card-text"><strong>Kontaktinformasjon: </strong> 95833897, nilsfors#gmail.com</p>
<DropdownButton id="dropdown-basic-button" variant="outline-primary"
title="Address">
<Dropdown.Item href="#/action-1">Address1 </Dropdown.Item>
<Dropdown.Item href="#/action-2">Address2</Dropdown.Item>
<Dropdown.Item href="#/action-3">Address3</Dropdown.Item>
</DropdownButton>
<p className="card-text"><strong>Adresse: </strong> Nøkken 7 H0101, 9016 Tromsø</p>
<p className="card-text"><strong>Passord: </strong> ***********</p>
<button className="btn btn-success">Rediger</button>
</div>
</div>
<div className="col-md-6 col-sm-12">
<div className="card mb-3 shadow-sm p-3 bg-white rounded" >
<h5 className="card-title" style={{ color: '#009540' }} ><strong>Nettverksanalyse</strong></h5>
<img className="card-img" variant="top" src="../images/testimg.png" style={{ width: '152px' }} />
<div style= { paragraph }>17:58:55: Henter nettverskinfo...<br/>
18:00:31: Nettverkstatus ok. Ingen feil funnet.</div>
<button className="btn btn-warning mt-2 text-center">See details</button>
</div>
</div>
</div>
<div className="row">
<div className="col-md-4 mt-5 text-center">
<div className="card mb-3 shadow-sm p-3 bg-white rounded" >
<div className="card-body">
<h5 className="card-title" style={{ color: '#009540' }}>Abonnement</h5>
<p className="card-text"><strong>Internett</strong></p>
<p className="card-text">Giga (1000/1000) Kr 699,- per mnd.</p>
Oppgrader
</div>
</div>
</div>
<div className="col-md-4 mt-5 text-center">
<div className="card mb-3 shadow-sm p-3 bg-white rounded">
<div className="card-body">
<h5 className="card-title" style={{ color: '#009540' }}>Faktura</h5>
<ul className="list-group" style= {{ float: 'left' }}>
<li><a className="card-link" href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}>Mars 2021</a></li>
<li><a className="card-link" href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}>Desember 2020</a></li>
<li><a className="card-link"href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}>Februar 2021</a></li>
</ul><ul className="list-group" style={{ float: 'right' }}>
<li><a className="card-link" href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}>Desember 2020</a></li>
<li><a className="card-link" href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}> November 2020</a></li>
<li><a className="card-link" href="https://www.homenet.no/" target="_blank" style={{ color: '#009540' }}>Oktober 2020</a></li>
</ul>
<div style={{ marginTop: '76px' }}> Se alle</div>
</div>
</div>
</div>
<div className="col-md-4 mt-5 text-center">
<div className="card mb-3 shadow-sm p-3 bg-white rounded">
<div className="card-body">
<h5 className="card-title" style={{ color: '#009540' }}>Kontakt oss</h5>
<p className="card-text">Kontakt oss via chat eller telefon 38 99 01 00.</p>
Chat
</div>
</div>
</div>
</div>
</div>
)
}
export default ProfileInfo
t's not the problem with react its with the CSS code. If you apply two rules that collide to the same elements, it will choose the last one that was declared. So put the #media queries to the end of the CSS page. i.e
.footer
.column
.social-column-container
.logo {
width: 100px;
height: auto;
display: inline-block;
margin-left: 50px;
}
#media only screen and (min-width: 900px) {
.footer
.column
.social-column-container
.logo {
display: none;
}
}

Import' and 'export' may only appear at the top level. But it is at the top level and end. (Gatsby & React JS)

I am creating a landing page and I have a simple error, but I cannot find the cause in my code. For me, the component is absolutely logical and the same structure as any other.
I am currently getting the following error based on this component:
./src/sections/landing/Prices.js
Module Error (from ./node_modules/eslint-loader/index.js):
C:\XXXXXXX\xxx-gatsby-1.4\xxx-gatsby\src\sections\landing\Prices.js
232:1 error Parsing error: 'import' and 'export' may only appear at the top level
230 | };
231 |
> 232 | export default Content;
| ^
233 |
✖ 1 problem (1 error, 0 warnings)
My code:
import React, { useContext } from "react";
import { Container, Row, Col } from "react-bootstrap";
import GlobalContext from "../../context/GlobalContext";
import imgC from "../../assets/image/l2/jpg/l2-content2-img.jpg";
const Content = () => {
const gContext = useContext(GlobalContext);
const Pricing1 = () => {
const [isMonthly, setIsMonthly] = useState(false);
return (
<>
{/* <!-- Content Area --> */}
<div className="content-section2 pt-12 pb-9 pt-lg-21 pb-lg-25 bg-default-2">
<Container>
<Row className="justify-content-center">
<Col xl="6" lg="8" sm="10">
<div className="section-title text-center mb-12 mb-lg-17">
<h2 className="title gr-text-4 mb-7">
Pricing & Plans
</h2>
<p className="gr-text-8 px-lg-7 px-xl-0">
With lots of unique blocks, you can easily build a page
without coding. Build your next landing page.
</p>
</div>
</Col>
</Row>
</Container>
<Container>
<div className="text-center pt-9">
<div
className="mb-13 d-inline-flex position-relative"
id="pricing-dynamic-deck--head"
>
<span className="period month gr-text-8 gr-text-color ">
Monthly
</span>
<a
href="/#"
className={`btn-toggle mx-3 price-deck-trigger ${
isMonthly ? "" : "active"
}`}
onClick={(e) => {
e.preventDefault();
setIsMonthly(!isMonthly);
}}
>
<span className="round"></span>
</a>
<span className="period year gr-text-8 gr-text-color">
Yearly
</span>
<span className="badge gr-badge text-primary gr-text-12 gr-bg-blue-opacity-1 rounded-pill ml-5 text-uppercase">
Save 25%
</span>
</div>
<Row className="justify-content-center">
<Col lg="4" md="6" sm="10" className="mb-9">
<div className="pricing-card bg-white gr-hover-shadow-1 border text-left pt-9 pb-9 pr-9 pr-xl-13 pl-9 pl-xl-13 bg-white rounded-10">
<div className="price-content">
<span className="small-title gr-text-12 text-primary font-weight-bold text-uppercase">
Starter
</span>
<div className="d-flex align-items-end mt-11 ">
<span className="currency mr-2 gr-text-6 font-weight-bold line-spacing-none text-blackish-blue">
$
</span>
<h2 className="price-value gr-text-2 font-weight-bold line-spacing-none mb-0 text-blackish-blue">
{isMonthly ? "49" : "19"}
<span className="d-none">.</span>
</h2>
<span className="per gr-text-9 text-blackish-blue">
/month
</span>
</div>
<span className="price-bottom-text gr-text-11 mt-5 text-blackish-blue gr-opacity-7 d-inline-flex">
{isMonthly ? "billed monthly" : "billed yearly"}
</span>
<ul className="card-list list-style-check pl-0 mt-7 mt-lg-11">
<li className="gr-text-9">
<i className="icon icon-check-simple"></i>Commercial
License
</li>
<li className="gr-text-9">
<i className="icon icon-check-simple"></i>100+ HTML UI
Elements
</li>
<li className="gr-text-9">
<i className="icon icon-check-simple"></i>Unlimited
Domain Support
</li>
<li className="disabled gr-text-9">
<i className="icon icon-simple-remove"></i>6 months
premium support
</li>
<li className="disabled gr-text-9">
<i className="icon icon-simple-remove"></i>Lifetime
updates
</li>
</ul>
</div>
<Button className="with-icon gr-hover-y px-xl-8 px-lg-4 px-sm-8 px-4">
Start Free Trial
<i className="icon icon-tail-right font-weight-bold"></i>
</Button>
<span className="btn-bottom-text d-block gr-text-11 text-blackish-blue gr-opacity-7 mt-5">
No credit card required
</span>
</div>
</Col>
<Col lg="4" md="6" sm="10" className="mb-9">
<div className="pricing-card bg-white gr-hover-shadow-1 border text-left pt-9 pb-9 pr-9 pr-xl-13 pl-9 pl-xl-13 bg-white rounded-10">
<div className="price-content">
<span className="small-title gr-text-12 text-primary font-weight-bold text-uppercase">
Standard
</span>
<div className="d-flex align-items-end mt-11 ">
<span className="currency mr-2 gr-text-6 font-weight-bold line-spacing-none text-blackish-blue">
$
</span>
<h2 className="price-value gr-text-2 font-weight-bold line-spacing-none mb-0 text-blackish-blue">
{isMonthly ? "99" : "49"}
<span className="d-none">.</span>
</h2>
<span className="per gr-text-9 text-blackish-blue">
/month
</span>
</div>
<span className="price-bottom-text gr-text-11 mt-5 text-blackish-blue gr-opacity-7 d-inline-flex">
{" "}
{isMonthly ? "billed monthly" : "billed yearly"}
</span>
<ul className="card-list list-style-check pl-0 mt-7 mt-lg-11">
<li className="gr-text-9">
<i className="icon icon-check-simple"></i>Commercial
License
</li>
<li className="gr-text-9">
<i className="icon icon-check-simple"></i>100+ HTML UI
Elements
</li>
<li className="gr-text-9">
<i className="icon icon-check-simple"></i>Unlimited
Domain Support
</li>
<li className="gr-text-9">
<i className="icon icon-check-simple"></i>6 months
premium support
</li>
<li className="disabled gr-text-9">
<i className="icon icon-simple-remove"></i>Lifetime
updates
</li>
</ul>
</div>
<Button className="with-icon gr-hover-y px-xl-8 px-lg-4 px-sm-8 px-4">
Start Free Trial
<i className="icon icon-tail-right font-weight-bold"></i>
</Button>
<span className="btn-bottom-text d-block gr-text-11 text-blackish-blue gr-opacity-7 mt-5">
No credit card required
</span>
</div>
</Col>
<Col lg="4" md="6" sm="10" className="mb-9">
<div className="pricing-card bg-white gr-hover-shadow-1 border text-left pt-9 pb-9 pr-9 pr-xl-13 pl-9 pl-xl-13 bg-white rounded-10">
<div className="price-content">
<span className="small-title gr-text-12 text-primary font-weight-bold text-uppercase">
Premium
</span>
<div className="d-flex align-items-end mt-11">
<span className="currency mr-2 gr-text-6 font-weight-bold line-spacing-none text-blackish-blue">
$
</span>
<h2 className="price-value gr-text-2 font-weight-bold line-spacing-none mb-0 text-blackish-blue">
{isMonthly ? "129" : "99"}
<span className="d-none">.</span>
</h2>
<span className="per gr-text-9 text-blackish-blue">
/month
</span>
</div>
<span className="price-bottom-text gr-text-11 mt-5 text-blackish-blue gr-opacity-7 d-inline-flex">
{" "}
{isMonthly ? "billed monthly" : "billed yearly"}
</span>
<ul className="card-list list-style-check pl-0 mt-7 mt-lg-11">
<li className="gr-text-9">
<i className="icon icon-check-simple"></i>Commercial
License
</li>
<li className="gr-text-9">
<i className="icon icon-check-simple"></i>100+ HTML UI
Elements
</li>
<li className="gr-text-9">
<i className="icon icon-check-simple"></i>Unlimited
Domain Support
</li>
<li className="gr-text-9">
<i className="icon icon-check-simple"></i>6 months
premium support
</li>
<li className="gr-text-9">
<i className="icon icon-check-simple"></i>Lifetime
updates
</li>
</ul>
</div>
<Button className="with-icon gr-hover-y px-xl-8 px-lg-4 px-sm-8 px-4">
Start Free Trial
<i className="icon icon-tail-right font-weight-bold"></i>
</Button>
<span className="btn-bottom-text d-block gr-text-11 text-blackish-blue gr-opacity-7 mt-5">
No credit card required
</span>
</div>
</Col>
</Row>
</div>
</Container>
</div>
</>
);
};
export default Content;
Probably it will be some simple syntax error or similar. I hope someone has an idea or finds the mistake.
You're missing } at the end. Should be:
const Content = () => {
const gContext = useContext(GlobalContext);
const Pricing1 = () => {
const [isMonthly, setIsMonthly] = useState(false);
return (
<>
<content..../>
</>
);
};
}
export default Content;

Resources