aboutsummaryrefslogtreecommitdiff
path: root/docs/runtime/jsx.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/runtime/jsx.md')
-rw-r--r--docs/runtime/jsx.md35
1 files changed, 35 insertions, 0 deletions
diff --git a/docs/runtime/jsx.md b/docs/runtime/jsx.md
new file mode 100644
index 000000000..1ace6e367
--- /dev/null
+++ b/docs/runtime/jsx.md
@@ -0,0 +1,35 @@
+Bun supports `.jsx` and `.tsx` files out of the box. Bun's internal transpiler converts JSX syntax into vanilla JavaScript before execution.
+
+```tsx#react.tsx
+function Component(props: {message: string}) {
+ return (
+ <body>
+ <h1 style={{color: 'red'}}>{props.message}</h1>
+ </body>
+ );
+}
+
+console.log(<Component message="Hello world!" />);
+```
+
+Bun implements special logging for JSX to make debugging easier.
+
+```bash
+$ bun run react.tsx
+<Component message="Hello world!" />
+```
+
+<!-- ### Prop punning
+
+The Bun runtime also supports "prop punning" for JSX. This is a shorthand syntax useful for assigning a variable to a prop with the same name.
+
+```tsx
+function Div(props: {className: string;}) {
+ const {className} = props;
+
+ // without punning
+ return <div className={className} />;
+ // with punning
+ return <div {className} />;
+}
+``` -->
an class='deletions'>-1/+1 2022-07-14docs: remove emulating cpu section (#714)Gravatar Robert Soriano 1-22/+0 2022-07-13docs: correct typo missing dots (#603)Gravatar pnxdxt 1-11/+11 2022-07-13docs: Substitute npm install with bun add (#670)Gravatar Fábio Santos 1-2/+2 2022-07-13fix(napi): gurantee -> guarantee (#683)Gravatar Ikko Ashimine 1-2/+2 2022-07-13fix(README): Add punctuation (#611)Gravatar Omer Shahar 1-31/+31 2022-07-13docs: Add bun-bakery template (#649)Gravatar Dennis Dudek 6-0/+69 2022-07-13fix: og:image share url (#678)Gravatar Gabriel Nunes 1-1/+1 2022-07-13add node:http Server polyfill (#572)Gravatar evan 2-2/+556 2022-07-13docs: Link esbuild and @evanw in README (#669)Gravatar Thomas Jaggi 1-1/+1 2022-07-13fix(env_loader): Off by one error (#668)Gravatar Finn R. Gärtner 1-1/+1 2022-07-13Typesbun-v0.1.4Gravatar Jarred Sumner 2-22/+27 2022-07-13switch from stream-browserify to readable-streamGravatar evanwashere 3-27/+1512 2022-07-13Add a console.log benchGravatar Jarred Sumner 3-0/+12 2022-07-13Add newline to symbols (fixes warning)Gravatar Jarred Sumner 1-1/+1 2022-07-13fix benchmark not building with old rust versionGravatar evanwashere 6-11/+11 2022-07-12[http] Fix assertionGravatar Jarred Sumner 1-1/+1 2022-07-12[bun.js] GC more stringsGravatar Jarred Sumner 2-4/+8 2022-07-12[bun install] Handle case that should really never happenGravatar Jarred Sumner 1-10/+12 2022-07-12[bun.js] Fix GC bug with `fetch`Gravatar Jarred Sumner 1-68/+29