
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
why-did-you-render
Advanced tools
Track why your vue components are updating
Sometimes a component is updating causing a rerender and you know that it shouldn't do it. Most of the times it is because a new object is created on some parent component, althought it hold the same values, it causes an update.
import WhyDidYouRender from 'why-did-you-render'
// install it as a global mixin
Vue.mixin(WhyDidYouRender)
export default {
name: 'MyComponent',
debug: true, // set this flag
}
It will log something like this
[WhyDidYouRender:watcher] MyComponent propName { val: currentValue, old: previousValue }
[WhyDidYouRender:watcher] MyComponentParent parentComputedName { val: currentValue, old: previousValue }
[WhyDidYouRender:UPDATED] MyComponent
We can see that the MyComponent
has updated and it has been caused by a prop named propName
and we can see too that its parent has also experience a mutation on something named parentComputedName
, it looks like the trigger which caused our component to update.
We will receive also the current and previous values of the mutated variables
Very simple, it just adds a watchers for everything inside the component with the debug: true
flag and does the same recursively for its parent recursively.
In a first instance I was skipping adding watchers on inner Vue attributes, those that start with _
or $
, but sometimes the mutation was caused by $attrs
or $listeners
when using v-on="$listeners"
or v-bind="$attrs
and this helps to track it too.
I just wanted something like https://github.com/welldone-software/why-did-you-render#readme but for Vue
FAQs
Track why your vue components are updating
The npm package why-did-you-render receives a total of 360 weekly downloads. As such, why-did-you-render popularity was classified as not popular.
We found that why-did-you-render 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.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.