Code Monkey home page Code Monkey logo

zustand-example's Introduction

왜 Zustand 인가?

사실 원래 recoil.js를 사용하려고 했다. 그 이유는 Redux보다 가볍기 때문인데 atom을 따로 적용하고 가져오는 건 zustand 에 있어서 store로부터 state 를 가져오는 것과 아주 유사하다고 생각한다.

또한, 훅으로 사용함에 있어서, zustand 와 recoil은 비슷한 모습인 것 같았다.

하지만, Recoil.js 같은 경우는 리액트에 묶여서 사용되어야하는데, zustand는 컴포넌트 밖에서도 state를 가져오거나 수정하는게 가능하다.

또한, atom, selector 와 같이 새로운 개념을 배우기엔 지금 내가 당장 다른 프로젝트에 전역상태 라이브러리를 채용해야하는 상황이였기 때문에, zustand의 부담없는 학습필요량은 나에게 이점으로 다가왔다.

그리고 무엇보다, 문서와 프로젝트의 규모가 zustand가 보다 더 잘 되어 있기 때문에, zustand를 채용했다.

코드 돌아보기

src 폴더 내에서 확인해야할 것은 아주 간단하다. App.tsxstore.ts 다.

본 프로젝트는 Vite로 시작한 카운터 앱이다.

간단하게 당장 전역 상태 라이브러리를 채용해야할 때, 위 두 파일 (두 파일의 전체 코드를 합쳐도 100줄이 안된다!) 을 참고하면 바로 적용할 수 있을만큼 간단하면서도 강력하다고 생각한다.

zustand-example's People

Contributors

blu3piece avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.