diff --git a/dev/concepts/fundamentals/component_defaults/index.html b/dev/concepts/fundamentals/component_defaults/index.html index 7f1fa191..c6fc4d08 100644 --- a/dev/concepts/fundamentals/component_defaults/index.html +++ b/dev/concepts/fundamentals/component_defaults/index.html @@ -24,7 +24,7 @@
Notice that we've set selected_items
to None
. None
values are treated as missing values, and so selected_items
will be set to [1, 2, 3]
.
Warning
The defaults are aplied only to keyword arguments. They are NOT applied to positional arguments!
Warning
When typing your components with Args
, Kwargs
, or Slots
classes, you may be inclined to define the defaults in the classes.
This is NOT recommended, because:
self.input
property.None
.Instead, define the defaults in the Defaults
class.
For objects such as lists, dictionaries or other instances, you have to be careful - if you simply set a default value, this instance will be shared across all instances of the component!
This is NOT recommended, because:
self.raw_kwargs
property.None
.Instead, define the defaults in the Defaults
class.
For objects such as lists, dictionaries or other instances, you have to be careful - if you simply set a default value, this instance will be shared across all instances of the component!
from django_components import Component
class MyTable(Component):
class Defaults:
@@ -58,4 +58,4 @@
}
We can access individual defaults like this: