Guest User

Untitled

a guest
Oct 28th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. import {createStore} from 'redux'
  2. import mainreducer from '../reducers/mainreducer'
  3.  
  4. const store=createStore(mainreducer);
  5. export default store;
  6.  
  7. export const USER_DATA = 'USER_DATA';
  8.  
  9. export function setUserData(user_data) {
  10. return {
  11. type: USER_DATA,
  12. user_data
  13.  
  14. }
  15. }
  16.  
  17. import {USER_DATA} from '../actions/actions'
  18.  
  19. function mainreducer(state = {
  20. user_data: null,
  21.  
  22. }, action) {
  23. switch (action.type) {
  24. case USER_DATA:
  25. return {
  26. ...state,
  27. user_data: action.user_data
  28.  
  29. };
  30. default:
  31. return state
  32. }
  33. }
  34. export default mainreducer;
  35.  
  36. ...
  37. const electron=require('electron');
  38. import React from 'react';
  39. import ReactDOM from 'react-dom';
  40. import {setUserData} from "../actions/actions";
  41. import store from '../store/store'
  42. ...
  43. class AuthForm extends React.Component {
  44. ......
  45. onClick() {
  46. let user_data={
  47. host: this.state.server,
  48. port: this.state.port,
  49. username: this.state.login,
  50. password: this.state.pass
  51. };
  52. store.dispatch(setUserData(user_data));
  53. ......
  54. }
Add Comment
Please, Sign In to add comment