IgnoreRender is a React component to ignore renders.
- :
🌅 : There is a first render regardless of theignore
value. 🔵 Ifignore
isfalse
, it works as usual.🔴 Ifignore
istrue
, everything inside IgnoreRender will NOT be rendered with the current data.♻️ Ifignore
changes fromfalse
totrue
, everything inside IgnoreRender will be rendered with the current data. Even if you called thesetState
at a time when the value ofignore
was equal totrue
.
Example
<div>1</div>
will always be there as long as ignore={true}
import IgnoreRender from 'react-ignore-render'
export default function MyComponent() {
const [second, setSecond] = useState(1)
useEffect(() => {
setSecond(2)
}, [])
return (
<IgnoreRender ignore={true}>
{() => (
<div>
{second}
</div>
)}
</IgnoreRender>
)
}