Selected language flag

React Issues

Created at "March 4, 2023". Last update at "March 21, 2023"

Article cover image - React Issues - React sticker
Image from Pexels.com

In this article you will find a compilation of issues that I have experienced while I learn, study, and work with React. Also, I will show you how I resolved that issues.

Error 0 - Console error on side navigation panel

Article image - React Issue 0

The first error only provoked a console error as you see at the top of this paragraph. It only ocurred when open the side menu panel of the app. In the next code lines:

Article image - React Code 0

The issue is because the hooks useTranslation and useState were after a conditional that returns. And a hook can not be executed after a condition that returns something.

Solution

The solution is to only put the hooks before the condition and that resolved it.

Error 1 - Error blank page on implement lazy loading

Article image - React Issue 0

The error was provoked when I wanted to implement lazy loading on some pages. I changed the imports from pages to imports using lazy function from React. After that the app started to crash. In the next code lines you can see an example:

Article image - React Code 0

The issue is because the hooks useTranslation and useState were after a conditional that returns. And a hook can not be executed after a condition that returns something.

Solution

The solution is change named export from page to default export and that is.

I will update this article with the same kinds of errors each time that I find one. That is all.

Colombia 2022 Implemented by Esteban Salazar with Nuxt. Design by Mely Rave . All rights reserved. Html5, CSS3 and Javascript icons by Icons8