What steps can be taken to resolve the delay in transition when clicking on "read less

I implemented a transition effect for the Read More and Read Less buttons, however, there seems to be a delay on the transition when clicking on the Read Less button. This delay was not intentionally set by me. How can I resolve this issue and also apply a transition effect to a gradient?

You can view my Code Sandbox project here: https://codesandbox.io/s/aged-breeze-bbqel

Answer №1

The issue lies not within react js itself, but rather in your css styling.

When you trigger a transition, the css for the Pure component style is executed with every click, causing a delay of 1.5 seconds to complete. To fix this, simply add a condition to the transition so that it only works on collapse events.

Change this:

transition: all 1.5s ease-in-out;

To this:

transition: ${(props) => (props.collapse ? "" : "all 1.5s ease-in-out")};

You can find a solution here

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

The state is failing to initiate a re-render despite a change in its state

In my React application, I have encountered an issue with combining two reducers. One of the reducers is functioning properly, but the other one is not triggering a re-render after a state change. Interestingly, when I save a document or make a change in t ...

Looking to organize and sum up values in DataTable REACT – is there a way to achieve this

I have a script that I'm working with and I want to group the data by the AKONT field and then totalize it based on the UM01S field. Is this something that can be done? const options = { UM01S: (item) => <td>{formatColumn('currency' ...

CSS/Jade/HTML: struggling to get boxes to align properly on the same line

I'm currently working with a Jade template that looks like this: extends layout block content h2 Characters and Portraits div(id="portraitsBox") - var portraits = ["Clown-Fox", "Dragon-Bear", "Fish-Bear", "Deer-Wolf", "Salamander-Ant", "Sid ...

Does anyone know of a way to integrate a calendar feature into a React application using a library

Greetings to everyone, I trust you are all enjoying a fantastic day. I am in search of an interactive calendar similar to this one for one of my applications Does anyone know of a React library that could assist me in creating such a feature? ...

What is the best way to hide the black icons (x) and bars on larger screens and which specific CSS code should I use to achieve this?

I'm attempting to display menu icons only on smaller screens like phones or tablets, and text on larger screens such as laptops or desktops. I've experimented with adjusting the media query and CSS, but haven't had any success. What specific ...

Is it necessary to implement a restful API for all database interactions in my Node.js application?

Currently, I am in the process of developing a simple blogging platform utilizing mongoose, node, express, Jade, and bootstrap. As I tackle the task of loading post content, I find myself contemplating whether to conduct database operations directly within ...

Issue: The type 'void' cannot be assigned to the type 'ReactNode' in the array.map() function

Having trouble with my function call error within the practice setup in App.tsx. My expectation of array.map() being compatible with TypeScript seems to be incorrect. The generated HTMLElement from this map is not displaying on screen. Any suggestions on ...

Combining TypeScript and JavaScript for efficient mixins

I came across an article on MDN discussing the usage and creation of mix-ins (link). Intrigued, I decided to try implementing it in TypeScript: type Constructor = new (...args: any) => any; function nameMixin(Base: Constructor) { return class extends ...

CSS clearfix doesn't appear to be functioning properly

I've been experimenting with using clearfix instead of the clear both property, but it's not working as expected. Despite following tutorials, the issue persists. How can I troubleshoot this and make it function properly? * { marg ...

Designing dynamic SVG elements that maintain uniform stroke widths and rounded edges

I'm currently tackling a project that involves creating SVG shapes with strokes that adjust responsively to the size of their parent container. My aim is for these shapes to consistently fill the width and height of the parent container, and I intend ...

The text on my website is experiencing a cropping issue on the right side

I'm having an issue where the right side of all the text on my website is being cut off. I've tried using Firebug to inspect the element, but it's always a paragraph text and they have different parent divs. I'm not sure what CSS adjust ...

Contrast between the visibility settings of display none and display block

Can you explain the contrast between a control's style being set to display: none versus display: block? ...

including a content tag into an input field within a template

I'm experimenting with the new html5 template tag to create a versatile form that can be used in various situations without relying heavily on javascript. Check out this fiddle to see what I have so far http://jsfiddle.net/684uH/ My objective is to ...

Conquering Challenges Across Multiple Disciplines

Is there a solution to solving the cross domain issues that arise when trying to fetch data from a different web server on the client-side, in violation of the Same Origin policy? ...

Reduce the width beyond the necessary limit

I'm struggling to adjust the width of an image to match it with the card size without stretching it or breaking the layout. Most solutions I've come across recommend using inline-block, but this doesn't work well for smaller images. It seems ...

Display Checkbox Selections in a Popup Message Box

I've run into a problem while working on an assignment. My goal is to show the checkbox values for toppings in the alert box popup upon submission. However, only the text box and radio values are displaying, while the checkbox returns as blank. Any ...

Obtain an Instance of a Class Using a Decorator

Delving deep into the world of decorators, I stumbled upon some fascinating ideas for incorporating them into my reflux implementation. My concept involves tagging a store's class method with an action, so that whenever that action is triggered, it au ...

conceal a division beneath a YouTube video frame upon clicking

I need to hide the 'div .blind' element when a YouTube video (inside 'div #player') is clicked. How can I achieve this? Here's an example: JS: ... var player; function onYouTubeIframeAPIReady() { player = new YT.Player('pl ...

Utilizing React hooks to determine the initial touch event position

I'm struggling with setting the initial position of a touch event. It appears to set one position and then remain unchanged. The intended functionality is that when swiping upwards, the number increases by one, and when swiping downwards, the count d ...

Exploring the contrast: resolve() versus fulfill() in q.js

I'm finding it difficult to understand the distinction between calling a resolver's resolve() as opposed to fulfill(). Both functions and terms "resolve a promise" and "fulfill a promise" are frequently used interchangeably. Can you provide guid ...