Spread props allow passing multiple props using spread syntax. Example: <Component {...props} />. Useful when forwarding many props. All properties of the object become individual props.
Components dispatch custom events using createEventDispatcher. Parent listens using on:eventName. Example: dispatch('message', data). Events bubble by default.
HTML attributes can be forwarded using $$props or $$restProps. Useful for wrapper components. Example: <div {...$$restProps}>. Passes any unhandled props to element.
Compound components share state through context. Implement parent-child communication. Handle component composition. Support flexible APIs. Manage shared state.
Prop testing verifies component behavior. Implement test utilities. Handle edge cases. Support integration testing. Manage test coverage.
Prop migrations handle schema changes. Implement migration strategies. Support data transformation. Handle migration errors. Manage migration state.
Props are declared using the export keyword in the script section. Example: export let propName. Optional props can have default values: export let propName = defaultValue. Props are passed to components as attributes.
Props are passed to child components as attributes in the markup. Example: <ChildComponent propName={value} />. Can use shorthand when prop name matches variable: <ChildComponent {value} />.
Event forwarding passes events up through components using on:eventName. Component can forward DOM events or custom events. Use on:message|stopPropagation to prevent bubbling.
Reactive statements ($:) respond to prop changes. Can trigger side effects or derive values. Example: $: console.log(propName). Runs whenever referenced props update.
Async props can be handled using promises or async/await. Handle loading states. Use reactive statements for async updates. Manage error states for async props.
Prop defaults are set in export statement or computed. Consider component initialization. Handle undefined values. Support dynamic defaults. Validate default values.
Prop documentation uses JSDoc or TypeScript. Generate documentation automatically. Support example usage. Handle deprecated props. Manage documentation updates.
Prop validation can be handled through TypeScript types or runtime checks. Use if statements or assertions in component initialization. Can throw errors for invalid props.
Two-way binding on props uses bind:propName. Example: <Input bind:value={name} />. Component must export the prop. Updates flow both ways between parent and child.
Prop watchers use reactive statements to observe changes. Can trigger side effects or validations. Handle prop updates asynchronously. Support complex watch conditions.
Event modifiers customize event behavior. Include preventDefault, stopPropagation, once, capture. Used with on: directive. Example: on:click|preventDefault. Support multiple modifiers.
Prop persistence saves prop values between renders. Use stores or local storage. Handle persistence lifecycle. Support value restoration. Manage persistence errors.
Advanced validation uses custom validators or schemas. Handle complex validation rules. Support async validation. Implement validation pipelines. Manage validation state.
Props can be destructured in export statement. Example: export let { name, age } = data. Supports default values and renaming. Makes prop handling more concise.
Prop types can be checked using TypeScript or runtime validation. Define interfaces for props. Implement validation in onMount or initialization. Handle type errors appropriately.
Computed props derive values from other props using reactive declarations. Example: $: fullName = `${firstName} ${lastName}`. Update automatically when dependencies change.
Prop transformation converts prop values before use. Use computed properties or methods. Handle data formatting. Support bi-directional transformation. Validate transformed values.
Dynamic event handlers change based on props or state. Use computed values for handlers. Support conditional events. Handle dynamic binding. Manage handler lifecycle.
Prop inheritance passes props through component hierarchy. Handle prop overrides. Support default inheritance. Implement inheritance rules. Manage inheritance chain.
Prop versioning handles breaking changes. Implement version migration. Support backwards compatibility. Handle version conflicts. Manage version state.
Prop serialization handles complex data types. Implement custom serializers. Support bi-directional conversion. Handle serialization errors. Manage serialized state.
Prop monitoring tracks prop usage and changes. Implement monitoring tools. Handle performance tracking. Support debugging. Manage monitoring state.