qat

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.

Edit the source to convert it in your browser

13 of 13 React constructs converted automatically

.tsx output

// @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>
  )
}

.qx output

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

PackageVerdictWhat it becomes
reactreplaced byqat
react-router-domreplaced by@qatjs/router
date-fnsworks as isframework-independent
@mui/materialkeep via bridge-reactReact components: mount them in a bridge-react island (its own React copy)