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.

"No outer <n-dialog-provider /> founded." when provider defined in App.vue template

See original GitHub issue

TuSimple/naive-ui version (版本)

2.28.0

Vue version (Vue 版本)

3.2.31

Browser and its version (浏览器及其版本)

Brave Version 1.35.101 Chromium: 98.0.4758.87

System and its version (系统及其版本)

MacOS(12.1)

Node version (Node 版本)

16.10.0

Reappearance link (重现链接)

https://codesandbox.io/s/8tw62k?file=/src/components/HelloWorld.vue

Reappearance steps (重现步骤)

Load the page

Expected results (期望的结果)

When I click the button, a dialog should appear

Actual results (实际的结果)

Compilation error: [naive/use-dialog]: No outer <n-dialog-provider /> founded.

Remarks (补充说明)

I have the n-dialog-provider defined on the top level App.vue

<template>
  <n-dialog-provider>
    <HelloWorld msg="Hello Vue 3 in CodeSandbox!" />
  </n-dialog-provider>
</template>

and am attempting to open up a dialog on a child component

<script>
import { useDialog } from "naive-ui";
export default {
  name: "HelloWorld",
  props: {
    msg: String,
  },
  data() {
    return {
      dialog: useDialog(),
    };
  },
  methods: {
    openDialog() {
      console.log(this.dialog);

      this.dialog.create({
        title: "Confirm",
        content: "Are you sure?",
        positiveText: "Sure",
        negativeText: "Not Sure",
        onPositiveClick: () => {
          console.log("Sure");
        },
        onNegativeClick: () => {
          console.log("Not Sure");
        },
      });
    },
  },
};
</script>

but am getting "No outer <n-dialog-provider /> founded." Am I misunderstanding where to define the dialog provider? Is there a component I need to import for the provider from naive-ui? The docs don’t seem to suggest that I need to…

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

0reactions
arrbaroncommented, Apr 12, 2022

I’ve modified the original sandbox with your suggestion and I’m still getting the error. (I’ve tried both with defineComponent and without, same result). Could you show me a working sandbox?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Component Registration - Vue.js
A Vue component needs to be "registered" so that Vue knows where to locate its implementation when it is encountered in a template....
Read more >
Vue template or render function not defined yet I am using ...
I had this script in app.js in laravel which automatically adds all components in the component folder.
Read more >
7 Ways to Define a Component Template in Vue.js
There are plenty of choices when it comes to defining component templates in Vue. By my count, there are at least seven different...
Read more >
Understand Routing in Vue.js With Examples | by SaidHayani
js Routers work by building a Vue- template as example . So, let's get started with our Vue.js Router project by installing and...
Read more >
Beginner Vue.js Tutorial with User Login - Auth0
This is how your application will handle routing. If you chose to have the router built-in using the CLI, you already have a...
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