-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
Components are undefined in HTML #20
Comments
Tried rewriting slightly differently but it has the same issue: layout/scripts/load_component.svelte<script context="module">
export const loadComponent = component => {
return import("../components/" + component + ".svelte").then(res => res.default).catch(err => null);
}
</script> layout/content/index.svelte<script>
export let title, intro, components, allNodes;
import { loadComponent } from '../scripts/load_component.svelte';
import { onMount } from 'svelte/internal';
let result;
onMount(async () => {
for (const obj of components) {
let compClass = await loadComponent(obj.component);
result = await compClass;
}
});
</script>
<svelte:component this="{result}" /> Per https://svelte.dev/tutorial/onmount
Edit: You don't need (revised) layout/content/index.svelte<script>
export let title, intro, components, allNodes;
import { loadComponent } from '../scripts/load_component.svelte';
let result;
(async () => {
for (const obj of components) {
result = await loadComponent(obj.component);
}
})();
</script>
<svelte:component this="{result}" /> |
It would be nice to eventually update the build script with sveltejs/svelte#958 |
I took a look at sveltejs/svelte#5476
Errors if install within node_modules folder
function insert(target, node, anchor) {
if (target != document) {
target.insertBefore(node, anchor || null);
}
}
This creates an array of filenames of components that were rendered during SSR called const { head, html, css, renderedComponents } = App.render({
answer: 42
}); An earlier attempt at this feature has some details about use: const { js } = //get test component, and apply custom filename option: compile(string, { filename: 'test' }
let Component = //turn JS into component
const { renderedComponents} = Component.render();
if(renderedComponents[0] !== 'test'){
//fail test
} Since we're compiling all the components manually in |
Related:
|
This should be working now using the I added some info about how to use this in a blog post in the default starter, but you can find more details in the docs here: https://plenti.co/docs/allComponents |
Working link to docs: https://plenti.co/docs/allcomponents/ The |
The default starter now includes a content driven component example inspired by #9.
This works well once the page hydrates, but the fallback HTML shows
undefined
instead of the component.The text was updated successfully, but these errors were encountered: