Components
Here you will learn about components in JSX Mail
In JSX Mail, files with the extensions .js
, .ts
, .jsx
, or .tsx
that are not located in the templates
folder are recognized as components.
For optimal organization, it’s advisable to create a components
folder inside the mail
directory. Here, you can store and manage your components.
Here’s a basic example to illustrate how to create a component:
Note that for components, the default
export is not mandatory. You can export any function, but it’s advisable to use a function name that matches the file name for clarity and consistency.
Unlike templates, components do not require an exported props
object. Simply use the props as needed within your component.
Components in Templates
You can easily import and utilize your components within templates. Here’s how you can incorporate the MyFirstComponent
into a template:
When you preview this template, it will display “Hello Theryston” with a red background, followed by “I’m your first component. My function is to show the user’s bio:” and the user’s bio.