
Security News
TC39 Advances 11 Proposals for Math Precision, Binary APIs, and More
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
effect-component
Advanced tools
Effect component is a port of the React.useEffect hook into render props. Available for the people who don't want/can't migrate into hooks right away.
On the hook, you'll normaly write it as follows:
import React, { useEffect } from 'react'
const MyComponent = ({ counter }) => {
useEffect(() => alert(`counter is now ${counter}`), [counter])
return <div>Counter is {counter}</div>
}
With this package:
import React from 'react'
import EffectComponent from 'effect-component'
const MyComponent = ({ counter }) => {
return <EffectComponent
effect={() => alert(`counter is now ${counter}`)}
checkValues={[counter]}
>
<div>Counter is {counter}</div>
</EffectComponent>
}
checkValues
: it works exactly as the 2nd parameter of React.useEffect
. Leaving it unset will call effect on every render. Setting it into []
will only call it on mount, and setting a value will only call it when the value changes.
effect
: You pass the function to act here, it can also return a cleanup function if is needed.
children
: Optional children to render, if is needed
FAQs
React Effect Hook on a Render Prop
The npm package effect-component receives a total of 52 weekly downloads. As such, effect-component popularity was classified as not popular.
We found that effect-component 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
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.