Skip to content

Instantly share code, notes, and snippets.

@Marxpark
Last active May 25, 2020 14:53
Show Gist options
  • Save Marxpark/6e663043f5469270d094976b54df574d to your computer and use it in GitHub Desktop.
Save Marxpark/6e663043f5469270d094976b54df574d to your computer and use it in GitHub Desktop.
injecting socket in App.js
import React from 'react';
import logo from './logo.svg';
import withSocket from "./withSocket"
import './App.css';
function App({socketListen, socketSend}) {
socketSend("message", {name: "i am connected"})
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
export default withSocket(App);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment