-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Update wording to include prop behaviour #4460
Conversation
In regards to sveltejs#4442, this adds wording to explain that props are set to undefined when they are removed by the consumer.
…ehaviour, for issue sveltejs#4442
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from the suggested change, it would be good to merge to me.
@mindrones Not sure about "instancing" as a verb. What about: "It will be used if the component's consumer doesn't specify the prop when the component is instantiated." ? |
Alternatively, "It will be used if the component's consumer doesn't specify the prop when instantiating the component." ? |
Sorry wrote in a hurry (also not native :), they're both OK to me, thanks! |
Co-Authored-By: Luca Bonavita <[email protected]>
Re: #4442 (comment) I'm not sure if we want to add that kind of suggestion in the reference. I tend to agree, but I'd prefer using something like: export let prop;
$: prop = prop || 'default'; |
Previously, these methods only applied to exported props. Also, add $$inject option to constructor, which injects state before running the update loop.
In regards to sveltejs#4442, this adds wording to explain that props are set to undefined when they are removed by the consumer.
…ehaviour, for issue sveltejs#4442
@mindrones Won't that cause a warning in development though? |
It would, but I'm not sure I'd want to see the form you suggested in the docs, although correct it's pretty long. Since this is a personal opinion I'd like to hear from others too :) |
@mindrones Agreed, this whole section is getting pretty long as it is :) Hm I rebased master in my branch and now all those extra commits are here. Not sure what I need to do to fix it if anything. |
Hm, not sure.. I'd try something like this:
|
Don't worry about all the extra commits - this will be squashed anyway when it is merged. I think this clarification sounds reasonable, thanks! |
docs: clarify default prop behaviour (sveltejs#4460)
Probably we should add a tutorial or guide on recommend how to provide a fallback value to props if it is undefined (technically falsey)? |
@tanhauhau agree, this would be good for a mini guide, see also #4442 (comment). Only problem the snippet suggested by @jesseskinner although correct isn't very attractive/sveltey, while the above one will give warnings. |
* 'master' of https://github.com/sveltejs/svelte: (137 commits) -> v3.19.2 fix lazy code breaks in build fit bitmask overflow initial dirty value in 'if' blocks (sveltejs#4507) add dev runtime warning for unknown slot names (sveltejs#4501) fix render fallback slot content due to whitespace (sveltejs#4500) docs: describe falsy and nullish attribute behavior (sveltejs#4498) in spread, distinguish never-updating and always-updating props (sveltejs#4487) chore: more specific typings, and add README note about Yarn (sveltejs#4483) update changelog check for unknown props even if component doesn't have writable props (sveltejs#4454) Bump codecov from 3.5.0 to 3.6.5 (sveltejs#4433) fix bitmask overflow for slot (sveltejs#4485) mark module variables as mutated or reassigned (sveltejs#4469) docs: referenced_from_script var value (sveltejs#4486) docs: clarify default prop behaviour (sveltejs#4460) site: turn fancybutton into custombutton (sveltejs#4476) update changelog exclude global variables from $capture_state (sveltejs#4475) -> v3.19.1 don't treat $$-names as stores during invalidation (sveltejs#4453) ...
If you dont want dublicate your defaults, will be better like this:
|
In regards to #4442, this adds wording to explain that props are set to undefined when they are removed by the consumer.
Before submitting the PR, please make sure you do the following
npm run lint
!)Tests
npm test
oryarn test
)