-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
31 lines (25 loc) · 783 Bytes
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import React from 'react';
import AppContainer from './screens/AppContainer';
import {createStore, applyMiddleware} from 'redux';
import createSocketIOMiddleware from 'redux-socket.io';
import io from 'socket.io-client'
const socket = io('http://192.168.0.13:3001');
const socketIoMiddleware = createSocketIOMiddleware(socket, 'server/')
function reducer(state = {}, action) {
switch(action.type) {
case 'message':
return {...state, message: action.data}
default:
return state;
}
}
const store = applyMiddleware(socketIoMiddleware)(createStore)(reducer);
store.subscribe(() => {
console.log("new state", store.getState())
})
store.dispatch({ type: 'server/hello', data: 'Hello' })
export default function App() {
return (
<AppContainer/>
);
}