You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

react-change-highlight

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-change-highlight

> React component to highlight changes in the wrapped component to enhance the UX and grap the focus of the user into the changed value of some parts like the cart in an e-commerce application for example.

1.0.4
Source
npmnpm
Version published
Weekly downloads
1.1K
19.87%
Maintainers
1
Weekly downloads
 
Created
Source

react-change-highlight

React component to highlight changes in the wrapped component to enhance the UX and grap the focus of the user into the changed value of some parts like the cart in an e-commerce application for example.

Install

yarn add react-change-highlight

or

npm install react-change-highlight

Usage

Basically you need to wrap the components you want to highlight on change inside HighlightChange element then add ref attribute to each child in this component to be used to be highlighted.

In the following example the count variable comes from state, so when ever that function setCount() is called with any different value the background of that wrapped div will be changed

import ChangeHighlight from 'react-change-highlight';

export default () => {
  const [count, setCount] = useState(0);

  <ChangeHighlight>
    <div ref={React.createRef()}>{count}</div>
  </ChangeHighlight>
}

Default styling for highlighting in case the user didn't use a custom styling using the highlightStyle property:

.react-highlight {
    background-color: #f8ffb4;
    transition: all 0.5s ease-in-out;
  }

Props

PropertyDescriptionTypeDefault
showAfternumber of milli seconds before start highlightingnumber500
hideAfternumber of milli seconds before ending highlightingnumber2500
containerClassNameclassName for component containerstring
highlightStyleclassName for highlighing contentstring
disabledweather you need to disable highlightingbooleanfalse

Author

  • Medhat Dawoud
  • Website: medhatdawoud.net
  • Twitter: @med7atdawoud

FAQs

Package last updated on 02 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts