This commit is contained in:
Philippe Torrel
2026-08-11 10:04:41 +02:00
parent a7dea7a7a6
commit f08771d221
271 changed files with 28827 additions and 4 deletions

View File

@@ -40,6 +40,7 @@ function App(props) {
<ThemeProvider>
<ExampleUseContext />
<hr />
<ExampleUseContext />
</ThemeProvider>
<hr />

View File

@@ -12,13 +12,13 @@ function reducer(state, action) {
const { type, payload = 1 } = action;
switch (type) {
case 'INCREASE':
return { counter: state.counter + 1 };
return { ...state, counter: state.counter + 1 };
case 'DECREASE':
return { counter: state.counter - 1 };
return { ...state, counter: state.counter - 1 };
case 'DOUBLE':
return { counter: state.counter * 2 };
return { ...state, counter: state.counter * 2 };
case 'INC_VALUE':
return { counter: state.counter + payload };
return { ...state, counter: state.counter + payload };
default:
console.warn('Action Type not found');

View File

@@ -1,6 +1,7 @@
import { createContext } from 'react';
export const THEME_DEFAULT_VALUE = 'light';
const ThemeContext = createContext(THEME_DEFAULT_VALUE); // standard theme is light;
// ThemeContext wird durch createContext() zu einem JSX-Element