Git Product home page Git Product logo

Comments (2)

AriPerkkio avatar AriPerkkio commented on September 24, 2024

There's also quite similar issue with assign statements.

use './utils' { addUser }

action addLoadedUser = assign(user, :addUser)

state idle {
  enter => addLoadedUser => loaded
}

state loaded {}

Output:

01 | import { createMachine, assign } from 'xstate';
02 | import { addUser } from './utils';   // Unused variable
03 | 
04 | export default function({ context = {} } = {}) {
05 |   return createMachine({
06 |     context,
07 |     states: {
08 |       idle: {
09 |         on: {
10 |           enter: {
11 |             target: 'loaded',
12 |             actions: ['addLoadedUser']
13 |           }
14 |         }
15 |       },
16 |       loaded: {
17 | 
18 |       }
19 |     }
20 |   }, {
21 |     actions: {
22 |       addLoadedUser: assign({
23 |         user: assigns.addUser // assigns is not defined
24 |       })
25 |     }
26 |   });
27 | }

I'm likely doing something wrong here, but following the example docs lead to these kind of issues.

from liblucy.

matthewp avatar matthewp commented on September 24, 2024

Ah so sorry for not replying before. If you're still interested, the : means that it is passed in through the machine function. Notice how in the first example it wants you to pass services.getUser.

To reference the imported method, simply reference it directly, no : needed:

use './utils' { getUsers }

state idle {
  invoke(getUsers) {
    done => assign(users)
  }
}

from liblucy.

Related Issues (20)

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.