0

enter link description here

I have given sandbox app link. What i am trying to do is route config for nested routes in react. I was able to do route for home,about and contact components. But when I am trying route child of contact component I am facing issue , when I am trying click child components blue & red it is getting disappearing as you can see in sandbox.

Can you help me out how to solve this issue.

Jerrin stephen
  • 204
  • 3
  • 12
  • 1
    async/await depends on promises. There are no promises in your code. – Mark Jun 15 '20 at 05:15
  • @vjr12 await does nothing in the above code. You can remove all asyncs and awaits (or add more) and the code behaves the same. – Mark Jun 15 '20 at 05:22
  • @MarkMeyer, you're incorrect regarding promises. The use of `async/await` _requires_ and _implies_ the availability of promises. He is simply mistaken in his assumption that "`await` keyword should be an blocking". It is not. – Aluan Haddad Jun 15 '20 at 05:25
  • you might need to return a promise in your function 'name' so when it's called in the function 'timer', it will actually wait til it is resolved – Karl L Jun 15 '20 at 05:26
  • @MarkMeyer I understand exactly what that says. Two things to be aware of are that: A) an `async` function/method _always_ returns a `Promise`. B) it is valid, although unhelpful to apply the `await` operator to values that are not Promises (ex: `await 1` is logically trasnformed to `await Promise.resolve(1)` – Aluan Haddad Jun 15 '20 at 05:30
  • @MarkMeyer, but I am quibbling with you because `name` most definitely `return` a `Promise` because it is an `async` function. Unfortunately, the bug is elsewhere. This isn't merely a pedantry because it actually has implications for execution order, exception handling, and control flow. – Aluan Haddad Jun 15 '20 at 05:35
  • "*what is the issue with when i am returning with settimeout function*" - the issue is that `setTimeout` does not return a promise, so there's nothing you can `await`. Returning `Promise.resolve("1")` from the callback function that you pass to `setTimeout` doesn't change that. – Bergi Jun 15 '20 at 08:07
  • @Bergi my first question is await will block or wait the promises alone ?. second question is async is a promise? , since i am returning a promise inside the setimeout function . promise is not getting returned right? – Jerrin stephen Jun 15 '20 at 08:12
  • 1
    Not sure I can make sense of these. "*await will block or wait the promises alone?*" - the `await` keyword does block the execution of the surrounding `async function` (but nothing else) until the given promise is settled. "*is async is a promise?*" - every `async function` returns a promise when called. "*i am returning a promise inside the setimeout function*" - but the `setTimeout` function will ignore the return value of that callback. – Bergi Jun 15 '20 at 08:16

0 Answers0