Skip to content

Commit c2728c9

Browse files
bouvydged-odoo
authored andcommitted
[DOC] slots prop validation
Make it explicit that props validation should accept `slots` if a component uses slots (even the `default` slot).
1 parent 871dad6 commit c2728c9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

doc/reference/props.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,28 @@ class ComponentB extends owl.Component {
320320

321321
Note: the props validation code is done by using the [validate utility function](utils.md#validate).
322322

323+
### `slots` prop
324+
325+
If a component that uses [slots](slots.md) also lists or validates its props, then
326+
you will have to explicitely allow the `slots` prop (with an `Object` type), or
327+
allow extra props using the `*` notation mentioned above. This is because slots
328+
are provided to a component [as props](slots.md#slots-and-props).
329+
330+
For example:
331+
332+
```js
333+
class MyComponent extends Component {
334+
static props = [someProp, slots?];
335+
}
336+
337+
class MyComponentWithValidation extends Component {
338+
static props = {
339+
someProp: {type: Number, optional: true},
340+
slots : {type: Object, optional: true},
341+
}
342+
}
343+
```
344+
323345
## Good Practices
324346
325347
A `props` object is a collection of values that come from the parent. As such,

0 commit comments

Comments
 (0)