prettier / prettier-vscode

Visual Studio Code extension for Prettier
https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
MIT License
5.18k stars 459 forks source link

prettier extremly load my cpu and show infinity saving file with 'prettier code formatter' #3217

Open nicitaacom opened 1 year ago

nicitaacom commented 1 year ago

You asked me about some additionl info - I got this here it is

"use client"

import Image from "next/image"
import { useState } from "react"
import { Carousel } from "react-responsive-carousel"
import "react-responsive-carousel/lib/styles/carousel.min.css"

import { AiFillCaretRight, AiFillCaretLeft } from "react-icons/ai"
import { twMerge } from "tailwind-merge"

interface SliderProps {
  images: string[]
  title: string
  className?: string
  containerClassName?: string
}

export function Slider({ images, title, className = "", containerClassName = "" }: SliderProps) {
  const [currentIndex, setCurrentIndex] = useState(0)
  const [isMoving, setIsMoving] = useState(false)
  const [direction, setDirection] = useState("")

  const goToPreviousSlide = () => {
    if (!isMoving) {
      setIsMoving(true)
      setDirection("left")
      setTimeout(() => {
        setCurrentIndex(prev => (prev === 0 ? images.length - 1 : prev - 1))
        setIsMoving(false)
      }, 300)
    }
  }

  const goToNextSlide = () => {
    if (!isMoving) {
      setIsMoving(true)
      setDirection("right")
      setTimeout(() => {
        setCurrentIndex(prev => (prev === images.length - 1 ? 0 : prev + 1))
        setIsMoving(false)
      }, 300)
    }
  }

  return (
    <figure className={twMerge(`relative w-full laptop:w-fit ${containerClassName}`)}>
      <Carousel
        showArrows={true}
        showIndicators={false}
        showStatus={false}
        showThumbs={false}
        width={480}
        ariaLabel="ariaLabelTest"
        axis="horizontal"
        emulateTouch={true}
        dynamicHeight={true}
        renderArrowNext={() => (
          <button className="absolute z-[88] top-0 bottom-0 left-0 w-[40px] bg-[rgba(0,0,0,0.4)] flex justify-center items-center"/>
        )}>
        {images.map((image, index) => (
          <Image
            className="w-[720px] h-[300px] object-cover"
            src={image}
            alt="image"
            width={360}
            height={180}
            key={index}
          />
        ))}
      </Carousel>
      {/* <button
        aria-label="next slide / item"
        className="absolute z-[88] top-0 bottom-0 left-0 w-[40px] bg-[rgba(0,0,0,0.4)] flex justify-center items-center"
        onClick={goToPreviousSlide}>
        <AiFillCaretLeft className="h-6 w-6 text-white" />
      </button>
      <button
        aria-label="next slide / item"
        className="absolute z-[88] top-0 bottom-0 right-0 w-[40px] bg-[rgba(0,0,0,0.4)] flex justify-center items-center"
        onClick={goToNextSlide}>
        <AiFillCaretRight className="h-6 w-6 text-white" />
      </button> */}
    </figure>
  )
}

I got this modifying this line

  renderArrowNext={() => (
          <button className="absolute z-[88] top-0 bottom-0 left-0 w-[40px] bg-[rgba(0,0,0,0.4)] flex justify-center items-center"/>
        )}>

just make this button as self-closing tag and just like normal button

Vegatality commented 12 months ago
image

Same here. I'm not exactly sure why this issue is occurring. It seems to happen randomly, and I'm having difficulty pinpointing the exact cause.

nicitaacom commented 12 months ago

It seems to happen randomly

I agree with that

So please authors don't ask us to reproduce it cause it happens randomly

github-actions[bot] commented 10 months ago

This issue has been labeled as stale due to inactivity. Reply to keep this issue open.

nicitaacom commented 10 months ago

This issue has been labeled as stale due to inactivity. Reply to keep this issue open.

Reply to keep this issue open

zackarydev commented 9 months ago

Is prettier optimized for monorepos? I'm having the same problem intermittently.

capaj commented 8 months ago

I am getting this too. Mostly on bigger projects/monorepos. Small projects are usually fine. Anyway size of the project should not matter when formatting currently selected file. Prettier extension is doing something it should not be.

rookledookle commented 7 months ago

Facing a similar issue - takes ages to format on save

github-actions[bot] commented 3 months ago

This issue has been labeled as stale due to inactivity. Reply to keep this issue open.

nicitaacom commented 3 months ago

Still open

nicitaacom commented 3 months ago

Not only I experience this issue - https://youtu.be/UKupfEuUc1M?t=655

github-actions[bot] commented 1 month ago

This issue has been labeled as stale due to inactivity. Reply to keep this issue open.

nicitaacom commented 1 month ago

Still waiting for fix...

FelippeRibeiro commented 1 month ago

same here...