<script src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.development.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.development.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
<script type="text/babel">
const { useState } = React;
const currentDate = new Date();
const currentDay = currentDate.getDay();
const firstDayOfWeek = new Date(currentDate);
firstDayOfWeek.setDate(currentDate.getDate() - currentDay);
const lastDayOfWeek = new Date(currentDate);
lastDayOfWeek.setDate(currentDate.getDate() + (6 - currentDay));
const firstDayString = firstDayOfWeek.toISOString().slice(0, 10);
const lastDayString = lastDayOfWeek.toISOString().slice(0, 10);
<div className='container'>
<h3>React Js Get First and Last Day of the Current Week</h3>
<p>First day of the week: {firstDayString}</p>
<p>Last day of the week: {lastDayString}</p>
ReactDOM.render(<App />, document.getElementById("app"));
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);