I'm having trouble with my react-big-calendar not updating when I switch between day, month, or week views -

Why won't my calendar change to the week view when I click on that section?

https://i.stack.imgur.com/gh2aO.png

In the screenshot above, my default view is set to month, but when I attempt to switch to week, it only highlights the option without changing the calendar structure.

https://i.stack.imgur.com/AF7bs.png

"use client";

import React, { useState } from "react";
import {
  Calendar as BigCalendar,
  CalendarProps,
  momentLocalizer,
} from "react-big-calendar";
import moment from "moment";

const localizer = momentLocalizer(moment);

const Schedules = (props: Omit<CalendarProps, "localizer">) => {
  const [isDialogOpen, setDialogOpen] = useState(false); // State to manage dialog visibility

  const openDialog = () => {
    setDialogOpen(true);
  };

  const closeDialog = () => {
    setDialogOpen(false);
  };

  const handleSelect = (slotInfo: any) => {
    // Handle date selection
    openDialog(); // Open the dialog when a date is selected
  };

  //Dates
  const today = new Date();
  const minDate = new Date(
    today.getFullYear(),
    today.getMonth(),
    today.getDate(),
    8
  );
  const maxDate = new Date(
    today.getFullYear(),
    today.getMonth(),
    today.getDate(),
    17
  );

  return (
    <div className="max-container padding-container h-[calc(100vh-15vh)] ">
      <BigCalendar
        className="p-4 shadow-2xl rounded-lg bg-slate-50 border-2 border-gray-20"
        selectable
        
        localizer={localizer}
        views={['day','week','month']}
        min={minDate}
        max={maxDate}
        onSelectSlot={() => {
          const modal = document.getElementById("my_modal_4") as HTMLDialogElement;
          if (modal) {
            modal.show();
          }}}
      />
      <dialog id="my_modal_4" className="modal">
        <div className="modal-box h-full w-full max-w-5xl">
          <h3 className="font-bold text-lg">Hello!</h3>
          <p className="py-4">Click the button below to close</p>
          <div className="modal-action">
            <form method="dialog">
              {/* if there is a button, it will close the modal */}
              <button className="btn">Close</button>
            </form>
          </div>
        </div>
      </dialog>
    </div>
  );
};

export default Schedules;

package.json

{
  "name": "sched",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@emotion/react": "^11.11.1",
    "@emotion/styled": "^11.11.0",
    "@mui/lab": "^5.0.0-alpha.148",
    "@mui/material": "^5.14.13",
    "@types/react-big-calendar": "^1.8.0",
    "class-variance-authority": "^0.7.0",
    "clsx": "^2.0.0",
    "moment": "^2.29.4",
    "next": "13.5.4",
    "react": "^18",
    "react-big-calendar": "^1.6.8",
    "react-dom": "^18",
    "tailwind-merge": "^1.14.0",
    "tailwindcss-animate": "^1.0.7"
  },
  "devDependencies": {
    "@types/node": "^20",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "autoprefixer": "^10",
    "postcss": "^8",
    "tailwindcss": "^3",
    "typescript": "^5"
  }
}

I am using Next.js with Tailwind CSS for this project.

CodeSandbox: https://codesandbox.io/p/sandbox/jovial-leftpad-ydxp3m?file=%2Fapp%2Fpage.tsx%3A41%2C11

Answer №2

Updating your next.config.js file can be a quick solution for this issue.

Here is the code to add:

const nextConfig = { reactStrictMode: false, }

If you need more information, please refer to this link.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

html interactive/expandable tree

I've come across this code which generates an HTML tree, but I'm facing an issue where the tree expands every time I refresh the page. What I want to achieve is to have certain branches expanded and others collapsed when the page is opened, depe ...

To develop a MUI Autocomplete feature in Next.js 13 with built-in error handling and smooth integration with a React form, follow these steps

For my latest project, I developed a custom Material-UI Autocomplete component called HsnComp, which can be found in the components/hsnComp.tsx file. The component is fully functional and you can see it in action on the provided CodeSandbox demo. It's ...

Oops! An error has occurred stating the need for a queue. This issue may be a result of a bug in React. Please report this problem by

Only encountering this error on the production environment, while everything runs smoothly on my local development machine using yarn dev. The issue seems to be related to the react-query hook useQuery. The error is happening within the component where th ...

Is there a way to display the button just once in a map function while still retaining access to the iteration value?

Utilizing formik within material-ui for a form has been quite productive. I've implemented a map function to print text fields and managed to display the Submit button only once by targeting the index. However, there's an issue when attempting to ...

What is the best way to create a compound query in Firebase?

I am working on a TypeScript script to search for a city based on its population... import { getFirebase } from "react-redux-firebase"; ... get fb() { return getFirebase(); } get fs() { return this.fb.firestore(); } getCollection(coll ...

Guide to iterating within a loop with a variable number of iterations above or below the specified amount in JavaScript

I am currently engaged in a project for a small theater group, and I am facing challenges with getting this loop to execute properly. <% include ../partials/header %> <div class="jumbotron jumbotron-fluid"> <div class="container"> ...

Delightful Bootstrap Tabs with Dynamic Content via Ajax

My website has a lot of tabs designed with Bootstrap. I wanted to make them responsive, so I tried using a plugin called Bootstrap Tabcollapse from https://github.com/flatlogic/bootstrap-tabcollapse (you can see a demo here: http://tabcollapse.okendoken.co ...

A guide to successfully interacting with multiple elements simultaneously at a single spot

Within my graphic chart, I have various dots that may be located in the same spot. I am looking for a way to handle clicks on two or more elements simultaneously in Vue 3. Do you know of any straightforward methods to achieve this? I attempted using refs ...

Executing a for loop just once in JavaScript

var door1 = {open: false,car: false,choose: false}; var door2 = {open: false,car: false,choose: false}; var door3 = {open: false,car: false,choose: false}; var carName = 0; var objectName = 0; var goatName = 0; var min = 1; var max = 4; var random = Math. ...

Efficient Techniques for Deleting Rows in a Dynamic JavaScript Table

I'm facing an issue where I want to remove each line added by the user, one by one. However, my current program is removing all the rows from the table instead of just one at a time. The objective is to allow the user to remove a specific row if they ...

What is the best way to transfer data entered into a textbox through an onclick Alert event into a database?

UI https://i.stack.imgur.com/c2cqo.png Here is the PHP code I have been struggling with. It is meant to save input data into a database, but I can't seem to get it right: if (isset($_POST['rjctrsn-data']) && !empty($_POST['rjc ...

Experience the combined power of addthis, isotope, and nicescroll - all in a single

I am utilizing a WordPress template that includes a set of share buttons from AddThis. <ul class="addthis extra"> <li class="addthis-hold"> <div class="addthis_toolbox" addthis:url="<?php the_permalink( ...

"Enhancing User Authentication with Firebase Email Verification in React Native

Does Firebase have a feature that allows me to verify if an email confirmation has already been sent to a user? I am able to check validation, but I need to determine whether the verification email has already been sent in order to decide if it needs to be ...

Transforming React-Leaflet Popup into a custom component: A step-by-step guide

Currently working on a project where I am utilizing both React-Leaflet and Material-UI by callemall. The challenge I am facing involves trying to incorporate the Material-UI Card component within the <Popup></Popup> component of React-Leaflet. ...

Serve a customized directory in production with Next.js

The issue at hand: Whenever I execute the command next build on my live server, the page appears unstyled during the building process. What I aim to achieve: Compile the application into a directory named build Transfer the contents of build to a director ...

Is there a method to access a website, trigger JavaScript functions, and subsequently retrieve the HTML content using PHP?

I am currently exploring options to access a webpage, execute JavaScript functions on it (thus altering the HTML content), and eventually save the modified version of the page. I'm uncertain if this approach is feasible, and if not, are there alternat ...

Display a unique button and apply a strike-through effect specifically for that individual list item

I've encountered an issue with my code that is causing problems specifically with nested LI elements under the targeted li element: $('#comment-section .comment-box a#un-do').hide(); $('#comment-section ul li[data-is-archived="true"]& ...

unable to modify the content within a div by clicking on a link

Lately, I've been experimenting with a code snippet I found on this fiddle: http://jsfiddle.net/unbornink/LUKGt/. The goal is to change the content of a div when clicking on links to see if it will work on my website. However, no matter which link I c ...

Importing an image from the public folder in a nested directory with Next.js

My images are stored in the public directory and all of my code is located in the src folder. Usually, when I try to import an image from src/page/page.js like: /image/logo/logo-dark.png, it works. But when I am importing images from the src/component/cor ...

Submitting a form into a database with the help of AJAX within a looping structure

Trying to input values into the database using AJAX. The rows are generated in a loop from the database, with each row containing a button column. Clicking on the button submits the values to the database successfully. The issue is that it only inserts va ...