diff --git a/src/index.jsx b/src/index.jsx index cc17ff4..f8297f3 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -6,6 +6,8 @@ import './styles/reset.css'; import './styles/main.scss'; import './styles/tabs.scss'; +import {StateProvider} from "./services/State"; + import {Nav} from "./components/Nav"; import {SearchBar} from "./components/SearchBar"; import {ScrollToTopRouter} from "./components/ScrollToTop"; @@ -22,22 +24,22 @@ const Main = (props) => { const navigate = (query) => props.history.push(`/search?query=${query}`); return ( - -

Busca la musica que te gusta!

- - -
+ +

Busca la musica que te gusta!

+ + +
) } const NoRoute = (props) => { return ( - -

Esa pagina no existe

- - - -
+ +

Esa pagina no existe

+ + + +
); } @@ -59,7 +61,23 @@ const App = () => ( ); +const AppWithState = () => { + const initialState = {theme: {primary: 'green'}}; + + const reducer = (state, action) => { + switch (action.type) { + default: return state; + } + }; + + return ( + + + + ); +} + ReactDOM.render( - , + , document.getElementById('root') ); diff --git a/src/services/State.jsx b/src/services/State.jsx new file mode 100644 index 0000000..76febae --- /dev/null +++ b/src/services/State.jsx @@ -0,0 +1,11 @@ +import React, {createContext, useContext, useReducer} from 'react'; + +export const StateContext = createContext(null); + +export const StateProvider = ({reducer, initialState, children}) => ( + + {children} + +); + +export const useStateValue = () => useContext(StateContext);