Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
preloadImages: 3, // 0 to 20
qualityImage: 100
};
const initialState = {
theme: getLSItem('theme') || 'light',
language: 'es',
displaySettings: displaySettingsLS || displaySettings,
coreSettings: coreSettingsLS || coreSettings
};
const {
GlobalStateProvider,
setGlobalState,
useGlobalState
} = createGlobalState(initialState);
export const setTheme = theme => {
window.localStorage.setItem('theme', theme);
setGlobalState('theme', theme);
};
export const setLanguage = language => {
setGlobalState('language', language);
};
export const setDisplaySettings = displaySettings => {
setLSItem('displaySettings', displaySettings);
setGlobalState('displaySettings', displaySettings);
};
export const setCoreSettings = coreSettings => {
import React, { StrictMode } from 'react';
import ReactDOM from 'react-dom';
import { createGlobalState } from 'react-hooks-global-state';
const initialState = {
count: 0,
text: 'hello',
};
const { GlobalStateProvider, useGlobalState } = createGlobalState(initialState);
const Counter = () => {
const [value, update] = useGlobalState('count');
return (
<div>
<span>Count: {value}</span>
<button type="button"> update(value + 1)}>+1</button>
<button type="button"> update(value - 1)}>-1</button>
</div>
);
};
const TextBox = () => {
const [value, update] = useGlobalState('text');
return (
<div></div>