Coder Social home page Coder Social logo

sty-mobx's Introduction

Mobx入门学习项目

项目环境

create-react-app初始化

babel 7.x

mobx 6.x

mobx-react 7.x

react 17.x

项目运行

npm start

http://localhost:3000

学习中遇到的问题

  • store更新但是UI没有更新

    原因是mobx 6.x版本不是使用@observable,改成使用makeAutoObservable或者makeObservable

  • Cannot update during an existing state transition (such as within render). Render methods should be a pure function of props and state

    react中事件绑定函数传参(此函数触发了更新store),没有使用箭头函数或者bind

    PS:太久没用react,忘记这个点了

  • 定义和使用computed

    定义:需要函数前面加get

    使用:不是函数调用,直接获取属性

项目中涉及知识点

  • store创建和使用
  • store的多模块
  • makeAutoObservable使用
  • makeObservable使用
  • 异步action(模拟,没使用mock)
  • computed
  • 装饰器的babel配置

说明

本项目写的比较粗糙,只适合mobx的入门学习,如有疑问,欢迎交流

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.