Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {createStore} from 'redux'
- import mainreducer from '../reducers/mainreducer'
- const store=createStore(mainreducer);
- export default store;
- export const USER_DATA = 'USER_DATA';
- export function setUserData(user_data) {
- return {
- type: USER_DATA,
- user_data
- }
- }
- import {USER_DATA} from '../actions/actions'
- function mainreducer(state = {
- user_data: null,
- }, action) {
- switch (action.type) {
- case USER_DATA:
- return {
- ...state,
- user_data: action.user_data
- };
- default:
- return state
- }
- }
- export default mainreducer;
- ...
- const electron=require('electron');
- import React from 'react';
- import ReactDOM from 'react-dom';
- import {setUserData} from "../actions/actions";
- import store from '../store/store'
- ...
- class AuthForm extends React.Component {
- ......
- onClick() {
- let user_data={
- host: this.state.server,
- port: this.state.port,
- username: this.state.login,
- password: this.state.pass
- };
- store.dispatch(setUserData(user_data));
- ......
- }
Add Comment
Please, Sign In to add comment