Mobx State Tree
구조는 리액트 및 다른 자바스크립트 프레임워크를 위한 state 관리 솔루션이다
Redux, the industry statndard for React state management, is very complex and includes a lot of boilerplate
이러한 Redux의 복잡성이 Mobx의 등장의 배경이 되었다
Mobx State Tree(MST) is an opinionated(독선적)이고 transactional state management solution built on top of Mobx
MST를 이해하기 위해서는
Tree
,Nodes
,Leaves
,Actions
,Views
,Snapshots
이 4개만 알면 된다!
nodes(model)
와 leaves(properties)
로 구성되어 있다Snapshot
를 사용한다Actions
tree
를 바꾸기 위해 사용된다Views
는 memorization(기억)을 위해 사용된다MST integration with React is easy with typescript decorators
npx create-react-app "파일명" --typescript
yarn
or npm install
yarn add uuid
yarn add @types/uuid -D
"experimentalDecorators": true,
추가>>App.tsx
import React from "react";
import logo from "./logo.svg";
import "./App.css";
interface Props {}
interface State {}
class App extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = {};
}
render() {
return (
<div>
<p>hi</p>
</div>
);
}
}
export default App;
여기서 error가 뜰 때 참고사이트
Cory 아저씨는
Single Root Store
이 더 간편해서 이 방법을 추천한다고 한다 '
우리가 만들 앱의 트리구조이다. 여기서 전체 diagram은
Tree/Stores
를, O(원)은
Node/Model
를 smallText 눈Leaf/Properties
를 뜻한다
출처 : Cory McAboy 유튜브