net-core-react-websockets
Intended usage with AspNetCore.WebSockets
Register SocketProvider
;;; ... const target = document;const socketOptions = port: 5001 // If undefined defaults to location.port host: 'localhost' // If undefined defaults to location.hostname path: 'ws'; ... const node = <Provider store=store> <SocketProvider options=socketOptions> <Router history=history onUpdate=onUpdate> appRoutes </Router> </SocketProvider> </Provider>; ;
Usage with socketConnect
;; { superprops; props; } { console } { const emitSocketEvent = thisprops; ; ; } { return <div> ... <div> ; } const onConnect = { console;} const onClose = { console; } const onMessage = { console;} const onError = { console;} App onConnect: onConnect onClose: onClose onMessage: onMessage onError: onError;
Access to socket object
;; { superprops; const socket = propssocket; } { return <div> ... <div> ; } App {};
Server side rendering
If you need to server side render the SocketProvider, use it without passing any options
... const createApp = ; ...