I'm trying to perform a simple algorithm in next.js and I'm getting this hydration errors.
This is the code I'm using:
import numeros from "../../functions/numberGenerators.js"
export default function teste(){
let number = numeros()
return number.map(n =>
<div key={n}>
Number: {n}
</div>)
}
And:
export default function megaSena(qtde = 6){
let listNumbers = []
while(listNumbers.length <= qtde - 1){
const numeroRandom = parseInt(Math.random() * 60) + 1
if (!listNumbers.includes(numeroRandom)){
listNumbers.push(numeroRandom)
}
}
return listNumbers
}
And I'm having these following errors:
1° - Error: Hydration failed because the initial UI does not match what was rendered on the server.
2° - Error: Text content does not match server-rendered HTML.
3° - Error: Hydration failed because the initial UI does not match what was rendered on the server.
4° - Error: There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.
What can I do to resolve this?