diff --git a/with-socket-io/app/App.js b/with-socket-io/app/App.js index c33358c..e01f12d 100644 --- a/with-socket-io/app/App.js +++ b/with-socket-io/app/App.js @@ -1,10 +1,10 @@ -import Expo from 'expo'; -import React from 'react'; -import { StyleSheet, Text, View } from 'react-native'; -const io = require('socket.io-client'); +import * as React from "react"; +import { StyleSheet, Text, View } from "react-native"; + +const io = require("socket.io-client"); // Replace this URL with your own, if you want to run the backend locally! -const SocketEndpoint = 'https://socket-io-expo-backend-dtyxsdtzxb.now.sh'; +const SocketEndpoint = "https://socket-io-expo-backend-dtyxsdtzxb.now.sh"; export default class App extends React.Component { state = { @@ -13,14 +13,14 @@ export default class App extends React.Component { }; componentDidMount() { const socket = io(SocketEndpoint, { - transports: ['websocket'], + transports: ["websocket"], }); - socket.on('connect', () => { + socket.on("connect", () => { this.setState({ isConnected: true }); }); - socket.on('ping', data => { + socket.on("ping", (data) => { this.setState(data); }); } @@ -28,11 +28,8 @@ export default class App extends React.Component { render() { return ( - connected: {this.state.isConnected ? 'true' : 'false'} - {this.state.data && - - ping response: {this.state.data} - } + connected: {this.state.isConnected ? "true" : "false"} + {this.state.data && ping response: {this.state.data}} ); } @@ -41,8 +38,8 @@ export default class App extends React.Component { const styles = StyleSheet.create({ container: { flex: 1, - backgroundColor: '#fff', - alignItems: 'center', - justifyContent: 'center', + backgroundColor: "#fff", + alignItems: "center", + justifyContent: "center", }, }); diff --git a/with-socket-io/backend/index.html b/with-socket-io/backend/index.html index b4fdec3..586a6ba 100644 --- a/with-socket-io/backend/index.html +++ b/with-socket-io/backend/index.html @@ -1 +1 @@ -Open it in Exponent! +Open it in Expo!