Migrate playground
Paste a React component: qatjs migrate converts it to .tsx and to .qx, and audits what it imports. It runs in your browser, in a worker.
13 of 13 React constructs converted automatically
// @ts-nocheck — migrated from JavaScript (Orders.jsx): add its types, then remove this line
import { For, If, derived, effect, state } from '@qatjs/core'
import { format } from 'date-fns'
import { Button } from '@mui/material'
export function Orders({ userId }) {
const orders = state([])
const queryValue = state('')
const shown = derived(() => orders().filter((o) => o.title.includes(queryValue())))
effect(() => {
fetch('/api/users/' + userId + '/orders').then((r) => r.json()).then(((value) => orders.set(value)))
})
return (
<section class="orders">
<input bind:value={query} placeholder="Filter" />
<If when={shown().length === 0}><p>No orders yet</p></If>
<ul>
<For each={shown()} key={(o) => o.id}>{(o) => <li>
<a href={'/orders/' + o().id}>{o().title}</a> {format(new Date(o().date), 'PP')}
</li>}</For>
</ul>
<Button onClick={() => orders.set([])}>Clear</Button>
</section>
)
}
import { format } from 'date-fns'
import { Button } from '@mui/material'
export function Orders({ userId }) {
let orders = state([])
let queryValue = state('')
let shown = derived(orders.filter((o) => o.title.includes(queryValue)))
effect(() => {
fetch('/api/users/' + userId + '/orders').then((r) => r.json()).then(((value) => (orders = value)))
})
return (
<section class="orders">
<input bind:value={query} placeholder="Filter" />
{if (shown.length === 0)}<p>No orders yet</p>{/if}
<ul>
{for (const o of shown)}<li key={o.id}>
<a href={'/orders/' + o.id}>{o.title}</a> {format(new Date(o.date), 'PP')}
</li>{/for}
</ul>
<Button onClick={() => (orders = [])}>Clear</Button>
</section>
)
}
Imports
| Package | Verdict | What it becomes |
|---|---|---|
react | replaced by | qat |
react-router-dom | replaced by | @qatjs/router |
date-fns | works as is | framework-independent |
@mui/material | keep via bridge-react | React components: mount them in a bridge-react island (its own React copy) |