ReactJS: Show/Hide different divs with different IDs using react hooks - reactjs

I have a feature in my project where I have different Icons that will show divs.
Here is my code so far:
const [drawerOpen, setDrawerOpen] = useState(false);
const [click, setClick] = useState(false);
const contextData = {
stateSetters: {
setDrawerOpen
}
};
<Row>
<Col md={8}>
<Card className="project-card">
<div>
<Icon type="down" onClick={() => {
setClick(!click);
contextData.stateSetters.setDrawerOpen(!click);
}}/>
</div>
</Card>
</Col>
<Col md={8}>
<Card className="project-card">
<div>
<Icon type="down" onClick={() => {
setClick(!click);
contextData.stateSetters.setDrawerOpen(!click);
}}/>
</div>
</Card>
</Col>
<Col md={8}>
<Card className="project-card">
<div>
<Icon type="down" onClick={() => {
setClick(!click);
contextData.stateSetters.setDrawerOpen(!click);
}}/>
</div>
</Card>
</Col>
</Row>
<div className={drawerOpen ? 'show-feature-drawer' : 'hide-feature-drawer'}>
<div className="feature-drawer" id="data-1">
</div>
</div>
<div className={drawerOpen ? 'show-feature-drawer' : 'hide-feature-drawer'}>
<div className="feature-drawer" id="data-2">
</div>
</div>
<div className={drawerOpen ? 'show-feature-drawer' : 'hide-feature-drawer'}>
<div className="feature-drawer" id="data-3">
</div>
</div>
I am looking for ways on how to open by calling its div id. I tried tweaking the onClick() but it still opens all the divs at once.

You need to specify the id of the drawer to open instead of the boolean value in state
const [drawerOpen, setDrawerOpen] = useState('');
const handleDrawerOpen = (data) => {
if(data === drawerOpen) {
setDrawerOpen('');
} else {
setDrawerOpen(data);
}
}
const contextData = {
stateSetters: {
setDrawerOpen: handleDrawerOpen
}
};
<Row>
<Col md={8}>
<Card className="project-card">
<div>
<Icon type="down" onClick={() => {
contextData.stateSetters.setDrawerOpen('data-1');
}}/>
</div>
</Card>
</Col>
<Col md={8}>
<Card className="project-card">
<div>
<Icon type="down" onClick={() => {
contextData.stateSetters.setDrawerOpen('data-2');
}}/>
</div>
</Card>
</Col>
<Col md={8}>
<Card className="project-card">
<div>
<Icon type="down" onClick={() => {
contextData.stateSetters.setDrawerOpen('data-3');
}}/>
</div>
</Card>
</Col>
</Row>
<div className={drawerOpen === 'data-1' ? 'show-feature-drawer' : 'hide-feature-drawer'}>
<div className="feature-drawer" id="data-1">
</div>
</div>
<div className={drawerOpen === 'data-2' ? 'show-feature-drawer' : 'hide-feature-drawer'}>
<div className="feature-drawer" id="data-2">
</div>
</div>
<div className={drawerOpen === 'data-3' ? 'show-feature-drawer' : 'hide-feature-drawer'}>
<div className="feature-drawer" id="data-3">
</div>
</div>

Related

Modal inside map is not rendering the data correctly according to the id

So I have a screen where I am showing details of a Medical Appointment, I have shown booked services in a table using a map function. Each row in table has a booked service info and reject button and accept button. I want to open a modal when any reject button is clicked,however the issue is that whenever I click any reject button the same modal opens,in other words the item.serviceData.serviceTitle shows the same name no matter which item I reject in the table row.
Can someone pls tell what the issue is
class AppointmentDetails extends Component {
constructor(props) {
super(props);
this.state = {
BookedServices: [],
Details:[],
Reject_Modal: false,
Lab_note: "",
UpdatedStatus:[],
Status: "Pending Response",
updatedappointment: [],
};
this.toggleRejectModal = this.toggleRejectModal.bind(this);
}
componentDidMount() {
// const{appointmentdetails}=this.props.match.params;
const {details}=this.props.location.state;
console.log(details);
this.setState({ BookedServices: details.BookedServices });
this.setState({ Details: details });
Status: this.state.Status;
// this.setState({ UpdatedStatus: this.state.UpdatedStatus });
// console.log(this.state.BookedServices);
//map through the booked services and display the services
}
componentDidUpdate(prevProps) {
if (this.props.details !== prevProps.details) {
this.setState({
BookedServices: details.BookedServices,
Details: details,
UpdatedStatus: this.state.UpdatedStatus,
Status: this.state.Status,
});
}
}
toggleRejectModal() {
this.setState(prevState => ({
Reject_Modal: !prevState.Reject_Modal,
}));
}
render() {
// const { invoiceDetail } = this.props;
const{ BookedServices,Details, UpdatedStatus, Lab_note, Status, updatedappointment}=this.state;
// const UpdatedStatus} =this.state.UpdatedStatus;
// const{Details}=this.state;
return (
<React.Fragment>
<div className="page-content">
<Container fluid>
<Breadcrumbs title="Pending Appointments" breadcrumbItem="Appointment Detail" />
{!isEmpty(Details) && (
<Row>
<Col lg="12">
<Card>
<CardBody>
<div className="invoice-title">
<p className="float-end text-muted font-size-12">
Appointment # {Details.id}
</p>
<div className="mb-4">
<img src={lablogohere} alt="logo" height="35" />
</div>
</div>
<hr />
<Row>
<Col sm="6">
<address>
<strong>Patient Information:</strong>
<br />
{Details.PatientType==="Self"?
<div>
<h6 className="mt-2">Name : {Details.PatientData.name} </h6>
<h6>Gender : {Details.PatientData.Gender}</h6>
<h6>Contact : {Details.PatientData.contact_number}</h6>
<h6>Email : {Details.PatientData.email}</h6>
</div>
:
<div>
<h6>Name : {Details.name} </h6>
<h6>Gender : {Details.Gender}</h6>
<h6>Contact : {Details.contact}</h6>
<h6>Email : {Details.PatientData.email}</h6>
<h6>Age : {Details.age} </h6>
</div>
}
</address>
</Col>
<Col sm="6" className="text-sm-end">
<address className="mt-2 mt-sm-0">
<strong>Address:</strong>
<br />
{Details.PatientType==="Self"?
<h6>{Details.PatientData.address}</h6>
:
<h6>{Details.Address}</h6>
}
<br />
</address>
</Col>
</Row>
<Row>
<Col sm="6" className="mt-3">
<address>
<strong>Date:</strong>
<br />
{Details.ReqDate}
<br />
<br />
</address>
</Col>
{/* <Col sm="6" className="text-sm-end">
<address>
<strong>Payment Method:</strong>
<br />
{Details.PaymentType}
<br />
</address>
</Col> */}
</Row>
<Row>
<div>
<h6><strong>Patient Note:</strong></h6>
<p>{Details.Notes}</p>
</div>
</Row>
<div className="py-2 mt-3">
<Row>
<Col xs="6">
<h3 className="font-size-15 font-weight-bold">
Appointment summary
</h3>
</Col>
<Col xs="6">
<h6 className="font-size-15 text-end">PKR.{Details.Price}</h6>
</Col>
</Row>
</div>
<div className="table-responsive">
<Table className="table-nowrap">
<thead>
<tr>
<th className=" text-center">Service Name.</th>
<th className=" text-center">HomeSampling</th>
<th className=" text-center">Communication</th>
<th className=" text-center">Requested Date-Time</th>
<th className=" text-center">Status</th>
<th className="text-center">Actions</th>
</tr>
</thead>
<tbody>
{map(
BookedServices,
(item, key) => (
<tr key={key}>
<td className=" text-center">{item.ServiceData.ServiceTitle}</td>
{item.HomeSampling === true ? <td className=" text-center"><h6 style={{color:"green"}}>✓</h6></td >: <td className=" text-center"><h6 style={{color:"red"}}>X</h6></td>}
{item.Communication === true ? <td className=" text-center"><h6 style={{color:"green"}}>✓</h6></td>: <td className=" text-center"><h6 style={{color:"red"}}>X</h6></td>}
<td className=" text-center">{item.RequestedTime}</td>
<td className="text-center"> <Badge
bg="danger"
className={"font-size-12 badge-soft-warning bg-soft-warning rounded-pill"}
// color={row.badgeclass}
>
{item.BookedServiceStatus}
</Badge></td>
<td className="text-center">
<Button
color="primary"
size="sm"
className="btn-pill mx-2"
onClick={() => {
this.setState({ UpdatedStatus: [...UpdatedStatus, { BookedServiceStatus: 'Accepted', id: item.id, Lab_note:null}] });
// this.setState.UpdatedStatus( [...UpdatedStatus, {BookedServiceStatus: "Accepted", id: item.id }])
// console.log(this.state.UpdatedStatus)
this.state.UpdatedStatus.map((item, index) => {
console.log(item)
if (item.BookedServiceStatus == "Accepted") {
this.setState({Status: 'Accepted'},()=>{
console.log("Status when accepted",this.state.Status)})
} else {
this.setState({Status: 'Rejected'},()=>{
console.log("Status when rejected",this.state.Status)}
)
}
}
)
}}
>
Accept
</Button>
<Button
color="danger"
size="sm"
className="btn-pill mx-2"
// onClick={this.toggleRejectModal}
// onClick={() => this.toggleRejectModal()}
onClick={e => {
e.preventDefault();
this.toggleRejectModal();
}
}
>
Reject
</Button>
</td>
<Modal
isOpen={this.state.Reject_Modal}
toggle={this.toggleRejectModal}
scrollable={true} // to enable scrollable body
centered={true} //to center the modal vertically
backdrop={"static"} //to disable click outside the modal
size="md">
<ModalHeader className="text-center">Reject Appointment
<button
type="button"
onClick={() => this.setState({ Reject_Modal: false })}
className="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">×</span>
</button>
</ModalHeader>
<ModalBody>
<h6>Service Name: {item.ServiceData.ServiceTitle} </h6>
<h6>Requested Time: {item.RequestedTime} </h6>
<Row>
<Col md={12}>
<Formik
enableReinitialize={true}
initialValues={{
Lab_note:
(this.state && this.state.Lab_note) || "",
}}
validationSchema={Yup.object().shape({
Lab_note: Yup.string().required(
"Please Enter reason for rejection"
),
})}
onSubmit={values =>
{
this.setState({ Lab_note: values.Lab_note })
let x= this.state.Lab_note
console.log("x",x)
}}
// this.setState(prevState => ({
// BookedService: {
// ...prevState.BookedService,
// Lab_note: values.Lab_note,
// }
// ,
// }));
>
{({
errors,
status,
touched,
values,
setFieldValue,
}) => (
<Form id="Detail-form">
<div className="mb-3">
<Label className="control-label">
Note:
</Label>
<Field
name="Lab_note"
type="text"
component="textarea"
rows={3}
onChange={e => {
this.setState({
Lab_note: e.target.value,
}),
setFieldValue(
"Lab_note",
e.target.value
);
}}
className={
"form-control" +
(errors.Lab_note &&
touched.Lab_note
? " is-invalid"
: "")
}
placeholder="Enter Reason for Rejection"
/>
<ErrorMessage
name="Lab_note"
component="div"
className="invalid-feedback"
/>
</div>
</Form>
)}
</Formik>
</Col>
</Row>
<Row>
<Col className="text-end">
<button
type="submit"
className="btn"
style={{
backgroundColor: "red",
color: "white",
}}
onClick={() =>
{
this.setState({ UpdatedStatus: [...UpdatedStatus, { BookedServiceStatus: 'Rejected', id: item.id, Lab_note:this.state.Lab_note}] });
// this.setState({ UpdatedStatus: [...UpdatedStatus, { BookedServiceStatus: 'Rejected', id: item.id, Lab_note:this.state.Lab_note}] });
// this.setState((state)=>
// ({ UpdatedStatus: state.UpdatedStatus.concat({ BookedServiceStatus: 'Rejected', id: item.id ,Lab_note:this.state.Lab_note })}
// ));
this.setState({ Reject_Modal: false })
this.setState({Lab_note: ""})
this.state.UpdatedStatus.map((item, index) => {
console.log(item)
if (item.BookedServiceStatus == "Accepted") {
this.setState({Status: 'Accepted'},()=>{
console.log("Status when accepted",this.state.Status)})
} else {
this.setState({Status: 'Rejected'},()=>{
console.log("Status when rejected",this.state.Status)}
)
}
}
)
}
}
>
Reject
</button>
</Col>
</Row>
</ModalBody>
</Modal>
</tr>
)
)}
</tbody>
</Table>
</div>
<div className="d-print-none">
<Row>
<Col lg="9">
</Col>
<Col lg="3" className="text-center">
<Button
color="success"
onClick={e=>{
e.preventDefault();
// this.state.UpdatedStatus.map((item, index) => {
// console.log(item)
// if (item.BookedServiceStatus == "Accepted") {
// this.setState({Status: 'Accepted'},()=>{
// console.log("Status when accepted",this.state.Status)})
// } else {
// this.setState({Status: 'Rejected'},()=>{
// console.log("Status when rejected",this.state.Status)}
// )
// }
// }
// )
this.props.onUpdateStatus(this.state.Status,this.state.UpdatedStatus, Details.id)}}
className="btn btn-success w-md mr-6"
>
Respond
</Button>
</Col>
</Row>
{/* <div className="float-end mr-5">
<Link
to="#"
className="btn btn-success w-md mr-4"
>
Respond
</Link>
</div> */}
</div>
</CardBody>
</Card>
</Col>
</Row>
)}
</Container>
</div>
{console.log(this.state.UpdatedStatus)}
</React.Fragment>
);
}
}

Showing categories using Wordpress wp-json in ReactJS

I wanted to know what I'm doing wrong, to extract the first category from the Wordpress api.
I have a list of posts, and I just need to show the category, no link or anything.
With the code below it is bringing me an empty value.
export default function Blog({ posts }) {
const { status } = useSession();
if (status === 'loading') return <Loading />;
const getCategories = async (id) => {
const response = await axios.get(`${process.env.API_CONTENT}/categories/${id}`);
const category = response.data;
return category;
};
return (
<BlogPosts>
<Container className="default">
{posts.map((post, i) => (
<Post key={i}>
<Row>
<Col className="post-image" md={6}>
<PostImage>
<Link href={`/blog/${post.id}`}>
<a title={post.title.rendered}>
<img className="image" src={post._embedded['wp:featuredmedia']['0'].source_url} />
</a>
</Link>
</PostImage>
</Col>
<Col className="post-container" md={6}>
<PostContent>
<Link href={`/blog/${post.id}`}>
<a title={post.title.rendered}>
<h2 className="title">{post.title.rendered}</h2>
</a>
</Link>
<PostDetails date={post.modified} category={getCategories(post.categories[0])} />
<div className="excerpt" dangerouslySetInnerHTML={{ __html: post.excerpt.rendered }} />
<Link href={`/blog/${post.id}`}>
<a className="link" title={post.title.rendered}>
LEIA MAIS +
</a>
</Link>
</PostContent>
</Col>
</Row>
</Post>
))}
</Container>
</BlogPosts>
);
}

React.JS Object passing during onclick event

I am new to react,
I am using card, when card "on click" i need to get the card object and place it in form dynamically,
(full code)
My code:
// reactstrap components
import {useState} from "react"
import {
Card,
CardHeader,
CardBody,
CardTitle,
Col,
Input,
FormGroup,
Form,
Container,
Row,
UncontrolledDropdown,
DropdownToggle,
DropdownItem,
DropdownMenu,
Button,
} from "reactstrap";
import Header from "components/Headers/Header.js";
import 'react-toastify/dist/ReactToastify.css';
import Navbar from "components/Navbars/modulenavbar"
import axios from "axios";
import React from "react";
import { Link } from "react-router-dom";
var apitoken= localStorage.getItem('apitoken');
const api=axios.create({baseURL:"https://api/v1/account"})
const options = {
headers: {'Authorization': apitoken}
}
const Accounts = () => {
const [accounts, setaccount] = React.useState([]);
const [loading, setLoading] = React.useState(true);
const [disabled, setDisabled] = useState(false);
React.useEffect(async () => {
const response = await api.get("/",options);
setaccount(response.data.response);
setLoading(false);
}, []);
if (loading) {
return <>Loading...</>;
}
function handleGameClick() {
setDisabled(!disabled);
}
This is were i get all my api value and append it
return (
<>
{accounts.map((student, index) => {
const { id, name, phone, email } = student //destructuring
return (
<>
<div style={{ width: "18rem" }} onClick={() => console.log(student)}>
I want to pass the object "Student" and use it in the default value of the forms shown below
<Card className="card-stats mb-4 mb-lg-1">
<CardBody>
<Row>
<div className="col">
<CardTitle className="h4 font-weight-bold mb-0">
{name}
</CardTitle>
<span className="h5">{phone}</span>
</div>
<div className="col">
<span className="h5">{email}</span>
</div>
</Row>
</CardBody>
</Card>
</div>
</>
)
})}
</>
)
}
Form Shows here
const Display = () => {
return (
<>
<Header />
<Container className="mt--7" fluid>
{/* Table */}
<Row>
<Col className="order-xl-1 " xl="2">
<CardHeader className="bg-white border-0">
<Row className="align-items-center">
<Col xs="8">
<Link to="/admin//accounts" className="ni ni-bold-left">
<span> View Account</span></Link>
</Col>
</Row>
</CardHeader>
<Card className="bg-secondary shadow navbar-nav-scroll">
<Accounts/>
</Card>
</Col>
<Col className="order-xl-1" xl="10">
<Card className="bg-secondary shadow">
<Navbar/>
<Row >
<Col className="shadow navbar-nav-scroll">
<Form>
<h6 className="heading-small text-muted mb-4">
Account Information
</h6>
<div className="pl-lg-4">
<Row>
<Col >
<FormGroup>
<label
className="form-control-label"
htmlFor="input-username"
>
Account Name
</label>
<Input
className="form-control-alternative"
id="input-username"
placeholder="Username"
type="text"
defaultValue={student.value}
/>
</FormGroup>
</Col>
</Row>
<Row>
<Col >
<FormGroup>
<label
className="form-control-label"
htmlFor="input-email"
>
Email address
</label>
<Input
className="form-control-alternative"
id="input-email"
placeholder="jesse#example.com"
type="email"
/>
</FormGroup>
</Col>
</Row>
<Row>
<Col >
<FormGroup>
<label
className="form-control-label"
htmlFor="input-email"
>
Phone
</label>
<Input
className="form-control-alternative"
id="input-phone"
placeholder="Phone"
type="text"
/>
</FormGroup>
</Col>
</Row>
</div>
</Form>
</Col>
<Col xs="9">
<Card className="card-stats mb-4 mb-lg-0">
<CardBody>
<div>
<Row className="align-items-center">
<Col xs="8">
</Col>
<Col className="text-right" xs="4">
<Button
color="success"
href="#pablo"
// onClick={save}
>
Save
</Button>
</Col>
</Row>
</div>
</CardBody>
</Card>
</Col>
</Row>
</Card>
</Col>
</Row>
</Container>
</>
);
};
export default Display;
Note:The above three sections of code is in the single component
I just want to dynamically append the values from object during "on click" event
Thanks in advance
You can store the clicked student value in state and pass it on to whichever component needs it as props
const Accounts = () => {
const [selectedStudent, setSelectedStudent] = useState({});
...
const handleStudentClick = (student) => {
setSelectedStudent(student)
}
return (
<>
{accounts.map((student, index) => {
const { id, name, phone, email } = student //destructuring
return (
<>
<div style={{ width: "18rem" }} onClick={() => handleStudentClick(student)}>
Now you can pass selected student as props to your child component

Create search box in the list in react js component

Please tell, how to carry out search in the list of components which code is specified below correctly?
The search should be performed by title or full description of the list item.
Component with list of Item components:
const PathItems = () => {
const dispatch = useDispatch();
const pathDescription = useSelector(state => state.firestore.ordered.pathDescription);
const handleClick = (path) => {
dispatch(selectPath(path));
}
if(pathDescription && pathDescription.length !== 0){
return (
<React.Fragment>
<Row>
<Col className="pl-0 border-right border-dark">
{pathDescription && pathDescription.map(item => (
<PathItem
key={item.id}
item={item}
onInfoChange={ handleClick }
/>
))}
</Col>
<Col>
<FullDecript/>
</Col>
</Row>
</React.Fragment>
)
} else {
return (
<h5 className="text-muted text-center text-middle">Add your first route</h5>
)
}
}
export default compose(firestoreConnect(()=> ['pathDescription']))(PathItems);
Item component code:
const PathItem = ({ item, onInfoChange }) => {
const handleClick = () => {
onInfoChange(item);
}
return (
<React.Fragment>
<Card as="a"
style={{cursor: 'pointer'}}
className={'mb-2'}
onClick={ handleClick }>
<Card.Body>
<Row className="align-items-center">
<Col xs={1}>
</Col>
<Col xs={7}>
<h5>{item.title}</h5>
{item.sDescript}
</Col>
<Col xs={4} className="text-right">
<label>{item.length}600 km</label>
</Col>
</Row>
</Card.Body>
</Card>
</React.Fragment>
);
}
export default PathItem;
General view of the described components
Thanks in advance)
...
const [searchQuery, setQuery] = useState("");
const inputEvent = (event) => {
const data = event.target.value;
console.log(pathDescription);
setQuery(data);
}
const filterItems = pathDescription && pathDescription.filter(item => {
return item.title.toLowerCase().includes(searchQuery.toLowerCase()) ||
item.fDescript.toLowerCase().includes(searchQuery.toLowerCase());
})
...
<Col className="pl-0 border-right border-dark" style={divStyle}>
<InputGroup className="mb-3">
<FormControl
type="text"
placeholder="Type..."
aria-describedby="basic-addon2"
value={ searchQuery }
onChange={ inputEvent }
/>
<InputGroup.Append>
<Button variant="outline-secondary">
<img
alt="Logo"
src="https://cdn1.iconfinder.com/data/icons/app-user-interface-line/64/search_focus_user_interface_app_zoom-256.png"
width="25"
height="25"
className="d-inline-block align-top"/>
</Button>
</InputGroup.Append>
</InputGroup>
{filterItems.sort((a, b) => b.favorite - a.favorite).map(item => (
<PathItem
key={item.id}
item={item}
onInfoChange={ handleClick }
/>
))}
</Col>

horizontal align card using map function ReactJS

I'm trying to align horizontal card using grid with react-bootstrap and map function
I'm using redux to bring the Data through the props so I create a JSON to traverse it with a function Map
this is a fraction of my code
render() {
//const { tablaCliente } = this.state
//const { isLoading } = this.state
const { entity } = this.props;
return (
<div>
<Header></Header>
<div className="col-xs-4">
<a className="btn btn-primary" href="/newclient">Nuevo Cliente</a>
</div>
<br />
<center>
<Spinner animation="border" role="status">
<span className="sr-only">Loading...</span>
</Spinner>
</center>
<Container>
{entity && entity.getAllEntities && entity.getAllEntities.length > 0 && entity.getAllEntities.map((item, index) => {
return (
<CardGroup value={item}key={index}>
<Card style={{ width: '1rem' }} >
<Card.Img variant="top" src="data:image/svg+xml;charset=UTF-8,%3Csvg%20width%3D%22286%22%20height%3D%22180%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20286%20180%22%20preserveAspectRatio%3D%22none%22%3E%3Cdefs%3E%3Cstyle%20type%3D%22text%2Fcss%22%3E%23holder_16b0e6bd8ef%20text%20%7B%20fill%3A%23999%3Bfont-weight%3Anormal%3Bfont-family%3AHelvetica%2C%20monospace%3Bfont-size%3A14pt%20%7D%20%3C%2Fstyle%3E%3C%2Fdefs%3E%3Cg%20id%3D%22holder_16b0e6bd8ef%22%3E%3Crect%20width%3D%22286%22%20height%3D%22180%22%20fill%3D%22%23373940%22%3E%3C%2Frect%3E%3Cg%3E%3Ctext%20x%3D%22107.203125%22%20y%3D%2296.3%22%3E286x180%3C%2Ftext%3E%3C%2Fg%3E%3C%2Fg%3E%3C%2Fsvg%3E" />
<Card.Body>
<Card.Title> Cliente {item.name}</Card.Title>
<Card.Text>
{item.description}
</Card.Text>
</Card.Body>
<ListGroup className="list-group-flush">
<ListGroupItem>Estado:{''}{JSON.stringify(item.state)}</ListGroupItem>
<ListGroupItem>Creado por: {item.createby}</ListGroupItem>
</ListGroup>
<Card.Body>
<Card.Link href="/cliente">Card Link</Card.Link>
<Card.Link href="/cliente">Editar</Card.Link>
</Card.Body>
</Card>
</CardGroup>)
})}
</Container>
</div>
);
}
I dont use react-bootstrap but u can achieve it by doing
<Container>
<div class='row'>
{this.map(value => {
return (
<div class='col-md-6'>
<Card />
</div>
)
});}
</div>
</Container>
This should work
Wrap the map function in row and the returning jsx in col
And dont just write a whole logic in jsx use functions or components

Resources