Version 13 of NextJS seems to be experiencing issues with the onClick event, but fear not as the component is utilizing the 'useClient

I was attempting to incorporate the select component into my project when I encountered an issue with the onClick function. It seems that it was not working properly, even though I made use of 'use client;' for my component.

"use client";
import React from "react";
import styles from "./select.module.scss";

...

export const ChartSelect: React.FC<{
  chartType: "monthly" | "yearly" | "half-yearly";
  setChartType: React.Dispatch<
    React.SetStateAction<"monthly" | "yearly" | "half-yearly">
  >;
}> = (props) => {
  ...

  const handleOnClick = (value: "monthly" | "yearly" | "half-yearly") => {
    console.log("handleOnClick");
    props.setChartType(value);
  };

  return (
    <div className={styles.wrapper}>
      <div className={styles.select}>{findLabelByValue(props.chartType)}</div>
      <div className={styles.dropdown}>
        {options.map((option) => (
          <div
            className={styles.option}
            onClick={() => {
              console.log("PURE ONCLICK");
              handleOnClick(option.value);
            }}
          >
            {option.label}
          </div>
        ))}
      </div>
    </div>
  );
};

Answer №1

Updating to version 13.4.16 resolved the issue for me.

It seems there is a known bug in the latest release:

https://github.com/vercel/next.js/issues/54269

I am experiencing difficulties with hot reload on the most recent version.

Answer №2

Updating my node version solved the issue for me!

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

React's Material-UI ToggleButtonGroup offers a seamless way

I'm having trouble getting the ToggleButton selected property from material ui to function properly with ToggleButton. I followed the Material Ui documentation and created a StyledToggleButton as shown below: const StyledToggleButton = withStyles({ ...

The operation could not be completed with exit code 1: executing next build on Netlify platform

Having trouble deploying my Next.JS site to Netlify due to a build error. The site was working fine previously. Any suggestions on how to resolve this issue? 3:43:14 PM: - info Generating static pages (2/6) 3:43:14 PM: - info Generating static pages (4/6) ...

Looking for a solution to an issue using the filter method in redux?

I'm struggling to correct an error in my code related to the data filter in Redux. Despite researching extensively on this topic, I haven't been able to find a solution to make the code work. Any help would be greatly appreciated. I suspect that ...

Using Material UI Slider along with Typescript for handling onChange event with either a single number or an

Just diving into Typescript and encountered an issue with a Material UI Slider. I'm trying to update my age state variable, but running into a Typescript error due to the typing of age being number and onChange value being number | number[]. How can I ...

Transform the Curly Braces within a string into an HTML span Element using JSX

Looking to parameterize a string like 'Hello {name}, how are you?' in React Component? Want to replace curly braces with variable text and highlight it using span/strong tag. Here's an example of the desired final result: Hello <span cla ...

FaunaDB facilitates the establishment of connections between various users, enabling them to connect and form friendships

In my scenario, I have a requirement to link two different user roles together. If these users agree to connect, new functionalities will be unlocked for them. This concept is similar to how friend requests function on platforms like Facebook or LinkedIn, ...

Unable to establish a new pathway in the index.js file of a Node.js and Express website running on Heroku

I recently made some changes to my index.js file: const express = require('express'); const path = require('path'); const generatePassword = require('password-generator'); const fetch = require('node-fetch'); const ...

What are some methods for singling out a specific table row?

When working on my app, I faced the task of importing a JSON file and displaying its contents in a table with 3 columns. However, there are two main issues that arose: Utilizing array index for the row key is not recommended due to the table also having ...

What could be causing the callback function to not function correctly within the HOC component?

I am encountering an issue while passing the state (setActive) to the ButtonsOur component and then trying to pass it to the HOC through a callback. The error message "Uncaught TypeError: setActive is not a function" keeps popping up. Could you please help ...

Increase the spacing between the dropdown menu and the first option

I am attempting to create some space between the select box and the dropdown list. An example image can be seen below: In the top example, a div was used. Despite trying padding and margins, I did not achieve the desired results. Is it impossible to do t ...

Having trouble customizing the Material UI button in React?

For a recent project, I utilized the older version (v1) of Material UI to ensure compatibility with Node 10.8. In order to implement a round button, I referred to this demo. The round mini button functioned perfectly without any applied themes. <Button ...

Synchronization problem with Apollo Client cache between multiple instances in a Next.js application using React Apollo and managed with pm2

Currently, I am utilizing Next.js and React Apollo for my application. To ensure optimal performance, I have configured my application to run with pm2 in a clustered mode featuring two instances. However, I have encountered an issue where switching user pr ...

Maximizing Input Field Utility in React JS

I have a challenge with retrieving values from the input field and passing it to the useEffect. I specifically want the search to be triggered only after pressing the onSearch function. The issue is that I can only capture the value using the onChange func ...

The SSR Next.js <Head> tag fails to render on the server side

import { getMeta } from '@/helpers/globalHelpers'; import Head from 'next/head'; import { useDispatch, useSelector } from 'react-redux'; import { increment, decrement, selectValue, bulkUpdate, reset } from '@/slicers/prop ...

Exploring the possibilities of integrating Next.JS and Clerk.com for seamless authentication with a .NET Web

I am a beginner in the world of react/next.js and I am currently working on setting up my application to interact with a backend .NET 8 WEB API. The WEB API setup can be found through this Link. Everything works smoothly when I initiate my WEB API in VS ...

Enhance user experience by customizing login functionalities in Meteor using React: Integrate personalized

Currently, I am utilizing account-ui to incorporate a drop-down login feature in Meteor. However, I have encountered an issue where I am unable to expand user sign-up functionality to include First and Last Name fields. This is because Meteor account ui on ...

Why isn't my onClick event functioning as expected?

I used the handleClick function in an onClick event, but it's showing an error (this is not defined). var Buttons = React.createClass({ getInitialState() { return { field: ':P ' } }, handleClick(field ...

Encountering a Firebase issue stating "invalid API key" upon deploying on Digital Ocean

I'm in the process of deploying my personal nextjs project, but encountered an error during the build: To run it, I set up a droplet on DigitalOcean and configured it to work with docker. Here's my Dockerfile: # Code for Dockerfile goes here... ...

When MUI Radio is selected, it passes both the label and value in the onChange event

I am currently working with reactjs and I have a MUI RadioGroup component. My goal is to pass the selected value's label along with it. Here is my Radio Button Code <RadioGroup aria-label="am-time-in" value={state.AM_time_in_valu ...

Exploring TypeScript and React Hooks for managing state and handling events

What are the different types of React.js's state and events? In the code snippet provided, I am currently using type: any as a workaround, but it feels like a hack. How can I properly define the types for them? When defining my custom hooks: If I u ...