-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Tutorial w/TypeScript] Warning: 'ArticlesCell' return type 'Element[]' not a valid JSX element. #5008
Comments
Suggestion: enhance the tutorial code snippets with a TypeScript tab so that first-timers can also learn about the correct types while working through it. |
@simoncrypta I've created a repository that follows each of the steps for your convenience, you can checkout / reset to Philzen/redwoodblog-tutorial-typescript@2acdd84 and play that through yourself. |
Typescript see success as an array of element (but I think it should be an array of component, but I don't know if this really change something) which is not, like the error say, a valid JSX component. I wrap the map function inside a React fragment to fix this. Maybe we should have done this way in the tutorial, but I let @cannikin decide what he thinks about that.
|
Also, the error will be fixed later in the tutorial
|
Thanks, of course that is the obvious solution and makes the error go away 👍 ... why didn't i think of that – i did actually try React fragment around IMHO it should be done that way for the time being in chapter 2 so RedwoodJS learners are left with valid code until they get to chapter 5. I took the liberty to prepare #5020 for this. |
This avoids warning `'ArticlesCell' cannot be used as a JSX component. Its return type 'Element[]' is not a valid JSX element.`. Closes redwoodjs#5008
This avoids warning `'ArticlesCell' cannot be used as a JSX component. Its return type 'Element[]' is not a valid JSX element.`. Closes redwoodjs#5008
This avoids warning `'ArticlesCell' cannot be used as a JSX component. Its return type 'Element[]' is not a valid JSX element.`. Closes redwoodjs#5008
This avoids warning `'ArticlesCell' cannot be used as a JSX component. Its return type 'Element[]' is not a valid JSX element.`. Closes #5008
Working through the tutorial in TypeScript mode, VSCode complains about the
ArticlesCell
return type:Interestingly, the warning doesn't appear while the
Success
function still returns the Articles wrapped in<ul>
, it only starts appearing when we change them to render as individual<article>
s as advised at the end of https://redwoodjs.com/docs/tutorial/chapter2/cells#our-first-cellHowever, wrapping
<ArticlesCell />
in a fragment or a div inHomepage.tsx
does not make the warning go away.Compilation succeeds nevertheless so it's possible to continue the tutorial, but still it would be nice to know which type to annotate the cell with so this warning goes away.
Reporting this non-critical finding here as advised.
The text was updated successfully, but these errors were encountered: