Giter VIP home page Giter VIP logo

Comments (8)

posva avatar posva commented on May 3, 2024 3

I see ๐Ÿ˜†
To me this is the kind of cases most people won't hit and when they do, they should be able to find a forum post or issue with the reasoning.
Putting it on the docs as a tip adds mental overhead that will be useless to most users and it's something we are avoiding and, instead, trying to integrate the explanation with the guide, to make the learning experience smoother

Side note: talking about laziness, using one letters for debugging purposes is even shorter and about as bad in readability as using the spread operator ๐Ÿ˜„ :

export default {
  setup(p, c) {
    console.log(c)
  }
}

from core.

KaelWD avatar KaelWD commented on May 3, 2024

It saves creating two proxy instances if the argument isn't used.

https://github.com/vuejs/vue-next/blob/b9479e2543fc24b65b6920bc9aaf17635d77f106/packages/runtime-core/src/component.ts#L442-L452

from core.

yangmingshan avatar yangmingshan commented on May 3, 2024

@KaelWD I know. But this is a trap, is it worth it? Maybe document it will help.

from core.

posva avatar posva commented on May 3, 2024

I don't think you are supposed to destructure the 2 arguments of setup like that.
Being able to avoid creating the Context object altogether for components not using it (all components that only rely on props) is a big perf boost. The only possible reason to use the spread like that is to pass the args again to a different function using the spread operator, so I think this is perfectly fine given the perf benefit

from core.

yangmingshan avatar yangmingshan commented on May 3, 2024

@posva I agree. And I think there needs to be some way to let people know about this, before they run into it, document maybe (in the future)?

from core.

posva avatar posva commented on May 3, 2024

How did you personally run into it and do you have any idea of other ways people will run into it? This will helps us to find the place it fits in the docs. Since most people won't use that syntax naturally nor by following the guide, it needs to be in the right place to be effective

from core.

yangmingshan avatar yangmingshan commented on May 3, 2024

I'm doing a small experiment, want to log both props and context, but I'm to lazy to write two parameters๐Ÿ˜…. Maybe people will write code like this when they debugging.

from core.

yangmingshan avatar yangmingshan commented on May 3, 2024

I got your point, nice discussion.

from core.

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.