Quick Redux Setup

Quick view of my directory
This is a Reducer
export const ADD_TAG = "ADD_TAG"export const DELETE_TAG = "DELETE_TAG"
import { combineReducers } from 'redux'
import currentTags from './currentTags'
export default combineReducers({
currentTags,
})
import { createStore } from 'redux'
import rootReducer from '../reducers'
export default createStore(
rootReducer,
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
)
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import { Provider } from 'react-redux'
import store from './Redux/store'
ReactDOM.render(
<React.StrictMode>
<Provider store={store}>
<App />
</Provider>
</React.StrictMode>,
document.getElementById('root'));
import React from 'react'
import { useEffect, useState } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { ADD_TAG, DELETE_TAG } from '../../Redux/types'
function Post() {const [tag, setCharTag] = useState('')const dispatch = useDispatch()
const tags = useSelector(state => state.currentTags)
function addTag(tag ) {
if (tags.length < 6){
dispatch({ type: ADD_TAG, payload: tag })
}
}
function deleteTag(tag) {
dispatch({ type: DELETE_TAG, payload: tag })
}
<IconButton onClick={() => addTag(tag)}>
<AddIcon />
</IconButton>
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store