Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rm useLayout and Add examples/advanced/tsx example
  • Loading branch information
CoinPool-Coin committed Aug 23, 2022
commit 8a409a555e3c4393aa0b67f5d1ed82d71fa1119f
9 changes: 9 additions & 0 deletions docs/content/4.examples/6.advanced/tsx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
template: Example
---

# Tsx

This example shows how to use `Tsx` in Nuxt pages and components

::sandbox{repo="nuxt/framework" branch="main" dir="examples/advanced/tsx" file="nuxt.config.ts"}
23 changes: 23 additions & 0 deletions examples/advanced/tsx/app.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script lang="tsx" setup>
const welcome = () => {
return <span>Welcome </span>
}
const nuxt3 = () => {
return <span>nuxt3</span>
}
const content = () => {
return (
<div>
{welcome()}
<span>to </span>
{nuxt3()}
</div>
)
}
</script>
<template>
<div>
<contentDom />
<content />
</div>
</template>
12 changes: 12 additions & 0 deletions examples/advanced/tsx/components/contentDom.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

let content: string = '`tsx` components exported using functions'

const contentDom = () => {
return (
<div>
<span>{content}</span>
</div>
)
};

export default contentDom
4 changes: 4 additions & 0 deletions examples/advanced/tsx/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { defineNuxtConfig } from 'nuxt'

export default defineNuxtConfig({
})
12 changes: 12 additions & 0 deletions examples/advanced/tsx/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "tsx",
"private": true,
"scripts": {
"build": "nuxi build",
"dev": "nuxi dev",
"start": "nuxi preview"
},
"devDependencies": {
"nuxt": "npm:nuxt3@latest"
}
}
3 changes: 3 additions & 0 deletions examples/advanced/tsx/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./.nuxt/tsconfig.json"
}
1 change: 0 additions & 1 deletion packages/nuxt/src/app/composables/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export { defineNuxtComponent } from './component'
export { useAsyncData, useLazyAsyncData, refreshNuxtData } from './asyncData'
export type { AsyncDataOptions, AsyncData } from './asyncData'
export { useHydration } from './hydrate'
export { useLayout } from './layout'
export { useState } from './state'
export { clearError, createError, isNuxtError, throwError, showError, useError } from './error'
export type { NuxtError } from './error'
Expand Down
6 changes: 0 additions & 6 deletions packages/nuxt/src/app/composables/layout.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/nuxt/src/auto-imports/presets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const appPreset = defineUnimportPreset({
'useAsyncData',
'useLazyAsyncData',
'refreshNuxtData',
'useLayout',
'defineNuxtComponent',
'useNuxtApp',
'defineNuxtPlugin',
Expand Down
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13109,6 +13109,14 @@ __metadata:
languageName: node
linkType: hard

"tsx@workspace:examples/advanced/tsx":
version: 0.0.0-use.local
resolution: "tsx@workspace:examples/advanced/tsx"
dependencies:
nuxt: "npm:nuxt3@latest"
languageName: unknown
linkType: soft

"type-check@npm:^0.4.0, type-check@npm:~0.4.0":
version: 0.4.0
resolution: "type-check@npm:0.4.0"
Expand Down