Answers for "React Hook useEffect has a missing dependency:'. Either include it or remove the dependency array."

1

Line 9:6: React Hook React.useEffect has a missing dependency: 'init'. Either include it or remove the dependency array

const fetchBusinesses = useCallback(() => {
  ...
}, [])
useEffect(() => {
  fetchBusinesses()
}, [fetchBusinesses])
Posted by: Guest on January-12-2021
0

React Hook useEffect has a missing dependency:'. Either include it or remove the dependency array.

import React, { useEffect, useState } from 'react';
import Todo from './Todo';
 
const TodoList = () => {
  const [todos, setTodos] = useState([]);
  useEffect(() => {
    fetch('https://jsonplaceholder.typicode.com/todos')
      .then(response => response.json())
      .then(data => {
        setTodos(data);
      })
  });
  return (
    <div>
      {
        todos.map(todo => (
          <Todo
            key={todo.id}
            title={todo.title}
            completed={todo.completed}
          />
        ))
      }
    </div>
  )
}
 
export default TodoList;
Posted by: Guest on January-06-2021

Code answers related to "React Hook useEffect has a missing dependency:'. Either include it or remove the dependency array."

Code answers related to "Javascript"

Browse Popular Code Answers by Language