Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
react-what-changed
Advanced tools
React What Changed - track which dependency changed between cycles
An efficient and simple library to show which dependency changed in a hook between react cycles.
npm install react-what-changed --save-dev
invoke this function again and again on each react's cycle to print which dependency has changed
import { reactWhatChanged } from 'react-what-changed';
Let's say we have the following component
import { reactWhatChanged as RWC } from 'react-what-changed';
function MyComponent(props) {
const [somePrimitive, setSomePrimitive] = useState(123);
const someArray = useSomeArray();
const someObject = useMemo(() => {
return { person: { name: 'John', age: 99 } };
}, [someArray]);
...
...
return <div></div>;
}
Example #1: simplest log as array
useEffect(() => {
someLogic();
}, RWC([somePrimitive, someArray, someObject]));
Example #2: verbose log as array
useEffect(() => {
someLogic();
}, RWC([somePrimitive, someArray, someObject], true));
Example #3: use ID for several logs
useEffect(() => {
someLogic();
}, RWC([somePrimitive], false, 'id_1'));
useMemo(() => {
someLogic();
}, RWC([someArray], false, 'id_2'));
useCallback(() => {
someLogic();
}, RWC([someObject], false, 'id_3'));
Example #4: log with dependencies names
// Instead of:
useEffect(() => {
someLogic();
}, RWC([
somePrimitive,
someArray,
someObject.person.name,
someObject.person.age,
]);
// Do this:
useEffect(() => {
someLogic();
}, RWC({
primitive: somePrimitive,
arr: someArray,
name: someObject.person.name,
age: someObject.person.age,
});
invoke this function again and again on an object (or array) to print all changes (deep comparison)
import { reactWhatDiff } from 'react-what-changed';
Let's use the same component from reactWhatChanged example.
Example #1: simple log
import { reactWhatDiff as RWD } from 'react-what-changed';
useEffect(() => {
someLogic();
}, [somePrimitive, someArray, RWD(someObject)]);
Example #2: use ID for several logs
useEffect(() => {
someLogic();
}, [somePrimitive, RWD(someArray, 'id_1'), RWD(someObject, 'id_2')]);
print all changes (deep comparison) between 2 objects (or arrays)
import { whatDiff } from 'react-what-changed';
Example #1: log the diffs between 2 objects
import { whatDiff as WD } from 'react-what-changed';
const obj1 = { name: 'John', address: { city: 'New York' } };
const obj2 = { name: 'John', address: { city: 'Paris' } };
WD(obj1, obj2);
Let's use the same component from reactWhatChanged example.
Example #2: simple log in a react component
const originalObject = useRef(someObject);
someLogic();
WD(someObject, originalObject.current);
React What Changed is APACHE-2.0 licensed.
FAQs
React What Changed - track which dependency changed between cycles
The npm package react-what-changed receives a total of 68 weekly downloads. As such, react-what-changed popularity was classified as not popular.
We found that react-what-changed demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.