Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

dependency list useeffect

import { useEffect, useState } from 'react';
function MyComponent({ prop }) {
  const [state, setState] = useState('');
  useEffect(() => {
    // Runs ONCE after initial rendering
    // and after every rendering ONLY IF `prop` or `state` changes
  }, [prop, state]);
}
Source by dmitripavlutin.com #
 
PREVIOUS NEXT
Tagged: #dependency #list #useeffect
ADD COMMENT
Topic
Name
5+9 =