You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A component is a reusable self-contained block of code that encapsulates markup, styles and behaviours that belong together.
Like Ractive and Vue, Svelte promotes the concept of single-file components: a component is just an .html file. Here's a simple example:
<h1>Hello {name}!</h1>
As only HTML is used in the .html file, this is either not a demonstration of, or a poor demonstration of the concept of including JS, HTML and CSS in a single file.
Additionally, since the file is called .html there is nothing to suggest there should be more inside the file than what is shown, ie, HTML.
Furthermore the component has data that is given to it later, on instatiation.
Suggestion
In the example below, I have avoided the use of obtuse language, tightened the copy and avoided the term 'SFC' as it does not serve a purpose - Svelte components are explained to be in a single file, we do not need a new acronym for this
Understanding Svelte components
Svelte applications are made from one or more components. In Svelte, like other frameworks, a component is a reusable self-contained block of code with HTML, CSS and JS in a single file.
@mikemaccana Actually, no one section is mandatory. Not only "hello world" component can be developed without any additional behavior or scoped styles:
@PaulMaly indeed not all the sections are mandatory - we could certainly have an even more minimal example per your REPL link.
The question is how well does it illustrate the concept of a single file component? The purpose of documentation is to explain things to users, not to be ultra optimised.
Current documentation
From https://svelte.technology/guide#understanding-svelte-components
As only HTML is used in the
.html
file, this is either not a demonstration of, or a poor demonstration of the concept of including JS, HTML and CSS in a single file.Additionally, since the file is called
.html
there is nothing to suggest there should be more inside the file than what is shown, ie, HTML.Furthermore the component has data that is given to it later, on instatiation.
Suggestion
In the example below, I have avoided the use of obtuse language, tightened the copy and avoided the term 'SFC' as it does not serve a purpose - Svelte components are explained to be in a single file, we do not need a new acronym for this
Understanding Svelte components
Svelte applications are made from one or more components. In Svelte, like other frameworks, a component is a reusable self-contained block of code with HTML, CSS and JS in a single file.
The text was updated successfully, but these errors were encountered: