Coder Social home page Coder Social logo

samuelalvin / react-mobx-mobxstatetree Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 1.0 68 KB

A simple application created in React with Mobx and Mobx-State-Tree for learning purpose.

License: MIT License

JavaScript 7.28% TypeScript 92.42% HTML 0.30%
react mobx mobx-react mobx-state-tree typescript

react-mobx-mobxstatetree's People

Contributors

samuelalvin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

tecla5

react-mobx-mobxstatetree's Issues

Add another example project in React for mobx-state-tree implementation

The example project will be used for a learning purpose. We'd like to see how far can we implement mobx-state-tree to a react project.

Requirement

  1. Please put the example project in a new folder in the examples folder,
  2. Use these fetch-data-from-api and redux-devtools-implementation example projects as the structure reference, and finally
  3. Create a pull request and then type in the description about what does the mobx-state-tree do in the project.

Typescript compile error happens when calling an action from another action of the same model

context

in typescript project

export const Project = types.model("Project", {
    id: types.number,
    name: types.string,
    isActive: types.optional(types.boolean, false)
})
.views(self => ({
    get root() {
      return getParent(self)
    },
    get  otherRoot() {
      return 'this is ok!' 
   },
    get isLoading(): boolean {
        return  self.root.isLoading
    }
}))
.actions((self) => ({
  ....
}));
export const ProjectStore = types.model("ProjectStore", {
    projects: types.array(Project)
})
.views(self => ({
    get isLoading(): boolean {
        return false
    }
}))
.actions((self) => ({
   .....
}));


export type IProject = typeof Project.Type;
export type IProjectStore = typeof ProjectStore.Type;

issue

when compile with typescript

error TS2339: Property 'root' does not exist on type '{ id: number; name: string; isActive: boolean; } & IStateTreeNode'.

seems getParent from mobx-state-tree cause this error

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.