Skip to content

Instantly share code, notes, and snippets.

@spencerfeng
Last active June 14, 2018 12:48
Show Gist options
  • Save spencerfeng/8465bb0a93f2a2c080720725f1f3b71b to your computer and use it in GitHub Desktop.
Save spencerfeng/8465bb0a93f2a2c080720725f1f3b71b to your computer and use it in GitHub Desktop.
For tutorial: How to use a single instance of Socket.IO in your React app
import React
import SocketContext from './socket-context'
import * as io from 'socket.io-client'
const socket = io()
const App = props => (
<SocketContext.Provider value={socket}>
<YourChildComponent />
</SocketContext.Provider>
)
export default App
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment