[redux] redux dispatch test

dev stefanCho·2021년 9월 18일
0

redux

목록 보기
1/3

React에서 Redux dispatch를 테스트할 수 있다.

Example

Redux Devtools를 사용하지 않고, 코드로 테스트하는 방식

// action-types.ts
export enum ActionType {
  INSERT_CELL_BEFORE = 'insert_cell_before',
}

// store.ts
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import reducers from './reducers';
import { ActionType } from './action-types';

export const store = createStore(reducers, {}, applyMiddleware(thunk));

// dispatch를 하고, state를 콘솔로 찍어본다.
store.dispatch({
  type: ActionType.INSERT_CELL_BEFORE,
  payload: {
    id: null,
    type: 'code',
  },
});

const state = store.getState();
console.log(state);
profile
Front-end Developer

1개의 댓글

comment-user-thumbnail
2022년 1월 9일

When selecting an accounting firm, small business owners must make certain that the firm they hire is capable of keeping up with the constantly changing nature of their industry and the rising digitalization of their industry. In accordance with websites like a https://fleet.care/ and other similar ones On a time-based basis, it is possible to keep track of the transportation's progress. Because of the large variety of activities that this web-based information technology computer application can do, it is probable that it will be advantageous to your vehicle operator company. Incorporated inside the accounting software is the responsibility for overseeing and regulating all parts of a company's financial reporting needs. This strategy is more efficient than other approaches since it does not need the use of time-consuming calculations. It is feasible to make use of it without having any prior accounting knowledge or experience. Because there are so many different types of accounting software packages available on the market, it may be difficult to establish which one is the best match for your needs. This technique, on the other hand, is far more easy provided you keep a few points in mind.

답글 달기