New App - Garden code example not working?
Hello all! I am kinda new to React and want to try updating my existing custom app using the new scaffold.
I started a new app in ZCLI with the react scaffold and it works locally (I see the list of orgs).
However, if I copy the code from https://garden.zendesk.com/components/autocomplete Default layout and replace the contents of app.js with it, I get the following error:
/src/javascripts/modules/app.js: Unexpected token, expected "," (40:19)
38 | */
39 | const filterMatchingOptionsRef = useRef(
> 40 | debounce((value: string) => {
| ^
41 | const matchedOptions = options.filter(
42 | option => option.trim().toLowerCase().indexOf(value.trim().toLowerCase()) !== -1
43 | );
Any ideas what I am doing wrong? I made no other modification to the scaffold created by zcli.
Also to note, I have tried this using npm and yarn - same issue.
-
Hi Steven Aranaga,
The sample code is typescript. I too have no experience with it, but I know it is used by pedantic people (whom I respect very much) and need to be explicit with the type of every variable. So in short, you should delete ": string" in javascript.
-
Thanks for that advice! Funny, it got passed that, but now I get this error.
-
I found that I couldn't replace the scaffold app.js. When I import the sample as another JS and put it inside the <render> tags, it works. So, the issue was there was this thing being built, but no command to display it.
Thank you again for your comment, but wanted to note this in case someone else comes across it.
Please sign in to leave a comment.
3 Comments