I'm trying to find a way to use the variable outside of a function in React. How can I use the variable "testing" outside of the reducer function?
const initialState = {count: 0};
function reducer(state, action) {
let testing = state.count;
switch (action.type) {
case 'increment':
return {count: state.count + 1};
case 'decrement':
return {count: state.count - 1};
default:
throw new Error();
}
}
const global = testing;