Validating component settings
Check the scale and duration of the score animation.
Use configDecoder to specify which values are allowed in data from JSON. In this example, the scale must be at least 1 and the duration must be at least 0. The SDK validates the settings before onInit. BlockPuzzleScoreComponent.ts
const ConfigDecoder = SchemaDecoder.object({
popScale: SchemaDecoder.number({ min: 1 }),
popDuration: SchemaDecoder.number({ min: 0 }),
});
type BlockPuzzleScoreConfig = InferDecoded<typeof ConfigDecoder>;
export class BlockPuzzleScoreComponent extends BaseTypedComponent<
BlockPuzzleScoreConfig,
Text
> {
protected override readonly configDecoder = ConfigDecoder;
}
dataSettings in JSON
configDecoderValidates the numbers
this.configThe component receives its settings