Last active
June 14, 2018 12:48
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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