2
respostas

Erro tela branca

Alguem poderia me ajudar com o codigo de erro que esta sendo gerado apos eu incluir o context?

Link do repositorio no gitub: https://github.com/BigPapa6911/cinetag.git

Object is not iterable (cannot read property Symbol(Symbol.iterator))
    at useFavoriteContext (favorites.js:19:1)
    at Card (index.js:8:1)
    at renderWithHooks (react-dom.development.js:16305:1)
    at mountIndeterminateComponent (react-dom.development.js:20074:1)
    at beginWork (react-dom.development.js:21587:1)
    at HTMLUnknownElement.callCallback (react-dom.development.js:4164:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:1)
    at invokeGuardedCallback (react-dom.development.js:4277:1)
    at beginWork$1 (react-dom.development.js:27451:1)
    at performUnitOfWork (react-dom.development.js:26557:1)
4react-dom.development.js:18687 The above error occurred in the <Card> component:

    at Card (http://localhost:3000/static/js/bundle.js:105:5)
    at section
    at Home
    at RenderedRoute (http://localhost:3000/static/js/bundle.js:39809:5)
    at Routes (http://localhost:3000/static/js/bundle.js:40299:5)
    at FavoritesProvider (http://localhost:3000/static/js/bundle.js:613:5)
    at section
    at Common (http://localhost:3000/static/js/bundle.js:217:5)
    at Router (http://localhost:3000/static/js/bundle.js:40237:15)
    at BrowserRouter (http://localhost:3000/static/js/bundle.js:38426:5)
    at AppRoutes

Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries.
logCapturedError @ react-dom.development.js:18687
react-dom.development.js:26923 Uncaught TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator))
    at useFavoriteContext (favorites.js:19:1)
    at Card (index.js:8:1)
    at renderWithHooks (react-dom.development.js:16305:1)
    at mountIndeterminateComponent (react-dom.development.js:20074:1)
    at beginWork (react-dom.development.js:21587:1)
    at beginWork$1 (react-dom.development.js:27426:1)
    at performUnitOfWork (react-dom.development.js:26557:1)
    at workLoopSync (react-dom.development.js:26466:1)
    at renderRootSync (react-dom.development.js:26434:1)
    at recoverFromConcurrentError (react-dom.development.js:25850:1)
2 respostas

Olá Gustavo, tudo bem?

Pelo erro apresentado, parece que o problema está no arquivo "favorites.js", na linha 19. O erro "Object is not iterable" indica que você está tentando iterar sobre um objeto que não é iterável.

Sugiro que verifique se o objeto que está sendo utilizado na linha 19 é realmente iterável. Caso não seja, você pode utilizar o método "Object.keys()" para obter as chaves do objeto e iterar sobre elas.

Outra sugestão é adicionar um error boundary ao seu código, para que possa tratar erros de forma personalizada. Você pode aprender mais sobre error boundaries em https://reactjs.org/link/error-boundaries.

Espero ter ajudado e bons estudos!

Faltou você colocar o FavoritosProvider no routes.js