#subscriptionEmail error
1 messages · Page 1 of 1 (latest)
Hi @vapid grail. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
This error is typically caused by using JSX syntax in a file with a .js extension. JSX syntax is used in React and is not recognized by JavaScript by default.
To resolve this issue, you can try the following steps:
-
Change the file extension from
.jsto.jsxor.tsxif you're using TypeScript. This will allow your development environment to recognize the JSX syntax. -
Ensure that you're importing React in the file where you're using JSX syntax. You can do this by adding the line
import * as React from 'react';at the top of your file. -
Check your
tsconfig.jsonfile to ensure that it's set up to handle JSX. You should have a line that says"jsx": "react-jsx"under thecompilerOptions.
Here's an example of how your file might look after making these changes:
import * as React from 'react';
export default function SubscriptionEmail() {
return (
<div>
// Your JSX code here
</div>
);
}
If you're still encountering issues after trying these steps, it might be helpful to compare your code with a working example. You can find an example of a Convex file that uses JSX syntax here (https://github.com/thomasballinger/convex-html-email-example/blob/main/convex/email.tsx).
Please note that these instructions are based on the information provided in the knowledge sources (https://discord.com/channels/1019350475847499849/1178924136010088489) and may not cover all possible causes of the error you're encountering. If you're still having trouble, I recommend reaching out to the Convex support team for further assistance.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@vapid grail kapa.ai is still learning and improving, please let us know how it did by reacting below
@gleaming pond the solution number three is actually the issue. Nextjs needs it to be preserve.
" We detected TypeScript in your project and reconfigured your tsconfig.json file for you. Strict-mode is set to false by default.
The following mandatory changes were made to your tsconfig.json:
- jsx was set to preserve (next.js implements its own optimized jsx transform)"
I could overwrite this but it seems like my app does not correctly when I change it to "react-jsx". Is there another work around?
Let me check the knowledge base for you. One moment! :books:
If you're using Next.js, it's indeed recommended to set "jsx": "preserve" in your tsconfig.json file. This is because Next.js has its own optimized JSX transform.
However, when working with Convex, you might encounter issues if you're trying to use JSX syntax in your Convex functions. This is because Convex expects the "jsx": "react-jsx" setting in the tsconfig.json file.
One possible workaround is to separate your Convex functions into a different directory and have a separate tsconfig.json file for that directory. This way, you can have different TypeScript configurations for your Next.js app and your Convex functions.
Here's an example of how you might structure your project:
/my-app
/convex
tsconfig.json
function1.tsx
function2.tsx
/next-app
tsconfig.json
pages/
components/
In the tsconfig.json file in the convex directory, you can set "jsx": "react-jsx". In the tsconfig.json file in the next-app directory, you can set "jsx": "preserve".