diff --git a/src/App.js b/src/App.js
index 2796bc7..8713ce8 100644
--- a/src/App.js
+++ b/src/App.js
@@ -7,6 +7,8 @@ import { SearchBar } from './components/SearchBar'
import './App.css'
import { LangSelect } from './components/LangSelect'
+import { Counter } from 'components/Counter'
+
export const App = () => {
const { t } = useTranslation()
return (
@@ -20,6 +22,7 @@ export const App = () => {
+
>
)
}
diff --git a/src/components/Counter.js b/src/components/Counter.js
new file mode 100644
index 0000000..e82d003
--- /dev/null
+++ b/src/components/Counter.js
@@ -0,0 +1,48 @@
+import React from 'react'
+import { useCounter, CounterProvider } from './CounterStore'
+
+export const Counter = () => {
+ return (
+
+
+
+
+
+
+
+
+ )
+}
+
+const Logger = () => {
+ const store = useCounter()
+ console.log(store[0])
+ return <>>
+}
+
+const MyCounter = () => {
+ const [{ counter }, { increment, decrement }] = useCounter()
+ return (
+
+ {counter}
+
+
+
+ )
+}
+
+const Text = () => {
+ const [{ text }] = useCounter()
+ return {text}
+}
+
+const TextSetter = () => {
+ const [{ text }, { setText }] = useCounter()
+ return (
+ setText(evt.target.value)}
+ />
+ )
+}
diff --git a/src/components/CounterStore.js b/src/components/CounterStore.js
new file mode 100644
index 0000000..2243ae1
--- /dev/null
+++ b/src/components/CounterStore.js
@@ -0,0 +1,22 @@
+import { createStore } from 'context-store'
+
+const initialState = {
+ counter: 0,
+ text: 'initial'
+}
+
+const thunks = {
+ increment: () => dispatch => dispatch(),
+ decrement: () => dispatch => dispatch(),
+ setText: text => dispatch => dispatch({ text })
+}
+
+const reducer = {
+ INCREMENT: state => ({ ...state, counter: state.counter + 1 }),
+ DECREMENT: state => ({ ...state, counter: state.counter - 1 }),
+ SET_TEXT: (state, { text }) => ({ ...state, text })
+}
+
+const store = createStore({ reducer, thunks, initialState })
+export const CounterProvider = store.Provider
+export const useCounter = store.useStore
diff --git a/webpack.config.js b/webpack.config.js
index dba1be0..36e873a 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -58,6 +58,7 @@ module.exports = (env, argv) => {
name: entrypoint => `runtime-${entrypoint.name}`
}
},
+ resolve: { modules: ['src', 'lib', 'node_modules'] },
plugins: [
// creat an index.html
new HtmlWebpackPlugin(),