Skip to content

Instantly share code, notes, and snippets.

import store from '../MyStoreAndMore.js'
class SecondScreen extends React.Component {
constructor(props, context) {
super(props, context);
this.state = store.getState();
store.subscribe(()=>{
this.setState(store.getState());
import store from '../MyStoreAndMore.js'
SetAlertState=(mynumber)=>{
console.log('set alert state')
store.dispatch({
type: "SetAlertCount",
payload: { AlertCount: mynumber, }
});
import { createStore} from 'redux'
const defaultState = {
AlertCount: null
};
function chatStore(state=defaultState, action) {
switch(action.type) {
case "SetAlertCount":
return {...state,
AlertCount: action.payload.AlertCount