r03181231 / redux-counter-basic Goto Github PK
View Code? Open in Web Editor NEWredux-basic-practice
redux-basic-practice
📕 Issue Feature
action value, action creator 생성
🧾Todo
// counter.js
// action value
export const PLUS_ONE = "plus_one";
export const MINUS_ONE = "minus_one";
// action creator : action value를 return하는 함수
export const plusOne = () => {
return {
type: PLUS_ONE,
};
};
export const minusOne = () => {
return {
type: MINUS_ONE,
};
};
📕 Issue Feature
리덕스 생성 및 세팅
🧾Todo
src/redux/config/configStore.js
src/redux/modules
configStore.js
// 중앙 데이터 관리소(store)를 설정하는 부분
import { createStore } from "redux";
import { combineReducers } from "redux";
const rootReducer = combineReducers({});
const store = createStore(rootReducer);
export default store;
import React from "react";
import ReactDOM from "react-dom/client";
import { Provider } from "react-redux";
import "./index.css";
import App from "./App";
import store from "./redux/config/configStore";
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
<Provider store={store}>
<App />
</Provider>
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
📕 Issue Feature
전체적인 작업사항을 입력해주세요
🧾Todo
counter.js
// counter.js
// 초기 상태값(state)
const initialState = {
number: 0,
};
//원래라면
// const [number, setNumber] = useState(0); 지만 위처럼 바꾼거야.
// 리듀서 : "state에 변화를 일으키는"함수
// (1) state를 action의 type에 따라 변경하는 함수
// state를 action 안에 있는 type에 따라서 변경하는 작업
// input : state, action
const counter = (state = initialState, action) => {
switch (action.type) {
default:
return state;
}
};
export default counter;
configStore.js
// 중앙 데이터 관리소(store)를 설정하는 부분
import { createStore } from "redux";
import { combineReducers } from "redux";
import counter from "../modules/counter";
const rootReducer = combineReducers({
//counter: counter 원래는 이 형태지만 단축 형태로 키밸류가 같으면 생략가능해(단축생략)
counter,
});
const store = createStore(rootReducer);
export default store;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.