diff --git a/content/en/guide/v10/api-reference.md b/content/en/guide/v10/api-reference.md index 97832b11f..f02e1de6c 100644 --- a/content/en/guide/v10/api-reference.md +++ b/content/en/guide/v10/api-reference.md @@ -102,7 +102,8 @@ The first argument must be a valid Virtual DOM Element, which represents either ```jsx const App = () =>
foo
; -// DON'T: Invoking components directly breaks hooks and update ordering: +// DON'T: Invoking components directly means they won't be counted as a +// VNode and hence not be able to use functionality relating to vnodes. render(App(), rootElement); // ERROR render(App, rootElement); // ERROR diff --git a/content/en/guide/v10/typescript.md b/content/en/guide/v10/typescript.md index 7e2d17a14..bc52b6e96 100644 --- a/content/en/guide/v10/typescript.md +++ b/content/en/guide/v10/typescript.md @@ -211,6 +211,23 @@ class Expandable extends Component { Class components include children by default, typed as `ComponentChildren`. +## Inheriting HTML properties + +When we write components like `` that wrap the HTML ``, most of the time we'd want to inherit +the props that can be used on the native HTML input element. To do this we can do the following: + +```tsx +import { JSX } from 'preact'; + +interface InputProperties extends JSX.InputHTMLAttributes { + mySpecialProp: any +} + +const Input = (props: InputProperties) => +``` + +Now when we use `Input` it will know about properties like `value`, ... + ## Typing events Preact emits regular DOM events. As long as your TypeScript project includes the `dom` library (set it in `tsconfig.json`), you have access to all event types that are available in your current configuration. diff --git a/content/en/tutorial/01-vdom.md b/content/en/tutorial/01-vdom.md index 16232424d..ca5c7a22f 100644 --- a/content/en/tutorial/01-vdom.md +++ b/content/en/tutorial/01-vdom.md @@ -162,7 +162,8 @@ in unexpected ways: ```jsx const App = () =>
foo
; -// DON'T: Invoking components directly breaks hooks and update ordering: +// DON'T: Invoking components directly means they won't be counted as a +// VNode and hence not be able to use functionality relating to vnodes. render(App(), rootElement); // ERROR render(App, rootElement); // ERROR