Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Vue warning #62

Merged
merged 1 commit into from
Apr 22, 2021
Merged

Fix Vue warning #62

merged 1 commit into from
Apr 22, 2021

Conversation

ahmedkandel
Copy link
Contributor

When visiting forgot-password page there is a console [Vue warn]: Extraneous non-props attributes (errors, auth) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.
The reason is Attribute Inheritance on Multiple Root Nodes

Inertia shares errors as a prop by default and Breeze shares auth as a prop by default. If those props are not explicitly defined on each page component a Vue runtime warning will be issued.

We can wrap all the root nodes of the page component in a <div> to create a single root component and get rid of the warning, But those props will be inherited as Non-Prop Attributes resulting in <div errors="[object Object]" auth="[object Object]">

Suggested solution : explicitly define errors and auth as props on each page component.

When visiting forgot-password page there is a console [Vue warn]: Extraneous non-props attributes (errors, auth) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.
The reason is [Attribute Inheritance on Multiple Root Nodes](https://v3.vuejs.org/guide/component-attrs.html#attribute-inheritance-on-multiple-root-nodes)

Inertia shares `errors` as a prop by default and Breeze shares `auth` as a prop by default. If those props are not explicitly defined on each page component a Vue runtime warning will be issued.

We can wrap all the root nodes of the page component in a `<div>` to create a single root component and get rid of the warning, But those props will be inherited as [Non-Prop Attributes](https://v3.vuejs.org/guide/component-attrs.html#non-prop-attributes) resulting in `<div errors="[object Object]" auth="[object Object]">`

Suggested solution : explicitly define `errors` and `auth` as props on each page component.
@taylorotwell taylorotwell merged commit fab1ce2 into laravel:1.x Apr 22, 2021
@reinink
Copy link
Contributor

reinink commented Apr 22, 2021

Yeah this solution is good, although it kind of sucks if you add additional top-level shared props.

But maybe that's the point...you probably shouldn't be constantly adding top-level shared props. Have auth, and errors, and try to stick to that, and be aware that any time you add additional top-level shared props, they will need to be explicitly set this way as well.

@reinink
Copy link
Contributor

reinink commented May 17, 2021

So, I think I figured out the right away to fix this issue. 🙌

See here: inertiajs/inertia#681

@ahmedkandel
Copy link
Contributor Author

@reinink you are right disabling inheritance by default is much cleaner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants