Enfield-li β 20-57 Jan 4
No sure what will possibly cause a simple problem like this: "can't access lexical declaration 'initialState' before initialization", can someone help me take a look the code, I am so cluless π΅βπ«
19 Replies
Unknown Userβ’4y ago
Message Not Public
Sign In & Join Server To View
I changed the const initialState to var
Unknown Userβ’4y ago
Message Not Public
Sign In & Join Server To View
the problem it disapeared
Unknown Userβ’4y ago
Message Not Public
Sign In & Join Server To View
that's the whole context page
maybe somewhere I imported cause problem?
Unknown Userβ’4y ago
Message Not Public
Sign In & Join Server To View
Ok, Let me check if that's the case
πΊ
Could the set up of createContext cause this, because this is the only place I can use initialState..
Unknown Userβ’4y ago
Message Not Public
Sign In & Join Server To View
Attaching Code
```js
// short code snippets go here
```
Link a Gist to upload entire files: https://gist.github.com
Link a Code Sandbox to share runnable examples: https://codesandbox.io/s
Link a Code Sandbox to an existing GitHub repo: https://codesandbox.io/s/github/<username>/<reponame>
Link a TypeScript Playground to share types: https://www.typescriptlang.org/play
Link a Snack to share React Native examples: https://snack.expo.io
Ok, I will try set up a sandbox..
Unknown Userβ’4y ago
Message Not Public
Sign In & Join Server To View
I don't understand what that means can you help me take a look at the code: https://codesandbox.io/s/zealous-bhaskara-lhi92
1076462153
CodeSandbox
zealous-bhaskara-lhi92 - CodeSandbox
zealous-bhaskara-lhi92 by 1076462153 using @testing-library/jest-dom, @testing-library/react, @testing-library/user-event, @types/jest, @types/node, @types/react, @types/react-dom, bootstrap, concurrently
Strange enough, code sandbox seems have no problem with it, but my local browser just completely broken because of it..
I have looked into some others' code, just found out that, simply moving the initialState to a different file and import it to relevant places, can solve the "circular dependency" problem. Thank you man, thank you for the hint @jcampuza πΊ
If it wasn't for the hint on that concept, these things makes no sense to me
Unknown Userβ’4y ago
Message Not Public
Sign In & Join Server To View
This thread hasnβt had any activity in 6 hours, so itβs now locked.
If you have a a followup question, you may reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/902647189120118794/928029505895944193
Threads are closed automatically after 6 hours, or if the member who started it reacts to a message with β
to mark that as the accepted answer.