40c6ec4fb0
* This example show how to use STOMP inside a Next.js application. * Fix useEffect * Add _app.js implementation * Fix lint error * Fix lint error * Update examples/with-stomp/README.md Co-Authored-By: Luis Fernando Alvarez D. <luis@zeit.co> * withStomp removed * The url address changed * _app.js removed. useClient added. * remove * revert * Add next.config.js * Updated readme
22 lines
460 B
JavaScript
22 lines
460 B
JavaScript
import React from 'react'
|
|
import useStomp from '../useStomp'
|
|
|
|
/**
|
|
* In this example you can easily connect to an Stomp Websocket server, and subscribe to a topic by a custom Hook.
|
|
*/
|
|
const Index = () => {
|
|
// get message
|
|
const message = useStomp('/any/topic')
|
|
|
|
// Check inside The message
|
|
console.log('##### new message : ', message)
|
|
|
|
return (
|
|
<div>
|
|
<h3>New Message:</h3>
|
|
<p>{message.text}</p>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default Index
|