question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The question about hooks

See original GitHub issue

I’ve just started using nuxt-property-decorator (I’m new with vue-property-decorator as well) and I would like to ask how you remember all the hooks. It’s totally unclear (on the first glance) why some class methods are hooks and the other are just methods. For example,

@Component
export default class ErrorLayout extends Vue {
  @Prop({ type: Object, default: null }) readonly error!: NuxtError
  
  test() {
    return 'test'
  }

  layout() {
    return 'empty'
  }
}

Layout is a hook and placed in the root scope while test is a method and placed inside methods. Isn’t it more intuitive to consider all the class’s methods as vue methods and have something like @AtRoot decorator if anything has to be placed on the root level?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:8

github_iconTop GitHub Comments

1reaction
wiktor-obrebskicommented, Jan 27, 2021

maybe all hooks function should be implemented on base Vue class, with empty body and proper typing? by this it should be much less possible to declare some random properties / functions with same names. and in case of migration - TypeScript would warn the user that the properties are in conflict.

1reaction
husaytcommented, Jan 26, 2021

Thanks @wiktor-obrebski, indeed we need to sort this out. If anyone has any suggestions, please.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Hooks Interview Questions | Backbencher.dev
Question : What are hooks in React? Answer: Hooks are a new feature added in React v16.8. It allows to use all React...
Read more >
27 Advanced React Hooks Interview Questions (ANSWERED ...
Q1: What are React Hooks? ... Hooks are a new addition in React 16.8. They let you use state and other React features...
Read more >
How to Write a Hook | Writing Studio
A question hook is when you ask the reader something that they can visualize and try to think of in their own minds....
Read more >
Top 10 Interview Questions Related To React Hooks
Top 10 Interview Questions Related To React Hooks · Q1. What Are React Hooks? · Q2. What is the primary benefit of Hooks?...
Read more >
Hooks FAQ - React
This page answers some of the frequently asked questions about Hooks. Adoption Strategy ... Do Hooks replace render props and higher-order components?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found