Open
Description
<script>
/**
* @type {string}
*/
export let entry;
import { doc, setDoc } from 'firebase/firestore';
import { SignedIn, SignedOut, Doc } from 'sveltefire';
import { firestore } from '$lib/firebase'; // your firestore instance
let editingNote = false;
let newNote = '';
function editNote(n) {
editingNote = true;
newNote = n;
}
async function saveNote(id) {
editingNote = false;
// set doc in firestore to newNote data
await setDoc(doc(firestore, 'words', id), {
note: newNote
});
}
</script>
{entry}
<Doc ref={`words/${entry}`} let:data>
{#if !editingNote && data?.note === undefined}
<SignedIn>
<button on:click={editNote(data?.note)}>Add Note</button>
</SignedIn>
{:else if !editingNote}
<p>{data?.note}</p>
<SignedIn>
<button on:click={editNote(data?.note)}>{data?.note ? 'Edit Note' : 'Add Note'}</button>
</SignedIn>
{:else if editingNote}
<form on:submit|preventDefault={saveNote(entry)}>
<textarea bind:value={newNote} />
<button type="submit">Save</button>
<button type="reset" on:click={() => (editingNote = false)}>Cancel</button>
</form>
{/if}
<p slot="loading">Loading...</p>
</Doc>
I can't get this to continue beyond the loading state despite everything else working. This component is Note.svelte and it is instantiated within the context of a so everything else is available.
Without the log option, I can't see what's wrong with the Doc component.
I turned off ssr in the svelte config as well:
import adapter from '@sveltejs/adapter-auto';
/** @type {import('@sveltejs/kit').Config} */
const config = {
ssr: false,
kit: {
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: adapter()
}
};
export default config;
What is going wrong?
Nothing in console as well btw
Metadata
Metadata
Assignees
Labels
No labels