rage-framework-example/apps/browser/src/App.tsx
2024-10-30 20:17:26 +00:00

29 lines
740 B
TypeScript

import { fw } from '@entityseven/rage-fw-browser'
import { useEffect, useState } from 'react'
function App() {
const [data, setData] = useState('initial')
useEffect(() => {
fw.event.register('customBrowserEvent', async message => {
setData(p => p + ' | ' + message)
const response = await fw.event.triggerServer('customServerEvent', [
'hello from browser',
])
setData(p => p + ' | ' + response)
return 'response from browser'
})
}, [])
return (
<div style={{ width: '100%', color: 'white', textAlign: 'center' }}>
<h1>Hello World!</h1>
<h2>{data}</h2>
</div>
)
}
export default App