Request: do not remove argType.defaultValue
in v 7.0
#18401
MichaelAllenWarner
started this conversation in
Ideas
Replies: 2 comments
-
@MichaelAllenWarner to make sure we're on the same page... Beforeexport default {
argTypes: {
foo: { defaultValue: 4 }
},
}; Afterexport default {
args: {
foo: 4,
}
} I'm confused why the latter could be considered less readable than the former. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Ah, I see the confusion. I'm talking about using export const Primary = {
// ...
argTypes: {
// ...
foo: {
// ...
defaultValue: 4
}
}
}
export const Secondary = {
...Primary,
argTypes: {
...Primary.argTypes,
foo: {
...Primary.argTypes.foo,
defaultValue: 8
}
}
} The deprecation advice would instead have me set |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I understand that
argType.defaultValue
has been deprecated, as explained here, where it's recommended: "If you were usingargType.defaultValue
or relying on inference to set a default value for an arg, you should now set a value for the arg at the component level."My 2¢ here is that using
argType.defaultValue
, co-located as it is with the rest of a story's arg-related information, is more convenient than having to put a default arg-value in the component-level metadata object (and results in more readable code for the same reason). It's also more flexible, since you can give each story in the file its own default value for a given arg.What's great about this feature is that it gives you the option of setting a default arg-value (that's in effect when the user visits the story in the UI) without having to set it on the story's actual
.args
object. I don't use it often, but sometimes I just don't want that value on the story's.args
, and when that happens I'm glad the option is there.Beta Was this translation helpful? Give feedback.
All reactions