Skip to main content

Advanced UI

In this codelab you will learn a handful of advanced UI topics.

This example relies on components from the Valdi_Widgets library. Projects created with valdi bootstrap already depend on it in MODULE.bazel. If you are working in a checkout of the Valdi repo instead, add it to the repo's MODULE.bazel:

bazel_dep(name = "valdi_widgets")
archive_override(
module_name = "valdi_widgets",
urls = ["https://github.com/Snapchat/Valdi_Widgets/archive/<release-tag>.tar.gz"],
strip_prefix = "Valdi_Widgets-<release-tag>",
)

Replace <release-tag> with a tag from the Valdi_Widgets releases, then add @valdi_widgets//valdi_modules/widgets to your module's deps.

Setup HelloWorld.tsx​

Let's clear out HelloWorld.tsx so we have a clean slate to work with.

It should look like

import { Component } from 'valdi_core/src/Component';

import { onRootComponentCreated } from './CppModule';

/**
* @ViewModel
* @ExportModel
*/
export interface ViewModel {}

/**
* @Context
* @ExportModel
*/
export interface ComponentContext {}

/**
* @Component
* @ExportModel
*/
export class App extends Component<ViewModel, ComponentContext> {
onCreate(): void {
onRootComponentCreated(this.renderer.contextId);
}

onRender(): void {
<view backgroundColor="white">
</view>;
}
}

Make sure it loads​

Connect a device or open an Android Emulator or iOS Simulator.

Start up the hotreloader.

cd apps/helloworld
valdi hotreload

Choose the //apps/helloworld:hello_world_hotreload target.

❯ valdi hotreload
✔ Running Bazel command: bazel query "attr(\"tags\", \"valdi_application\", //...)"
? Please choose a target to hot reload: (Use arrow keys)
❯ 1. //apps/helloworld:hello_world_hotreload
2. //apps/navigation_example:navigation_example_app_hotreload
3. //apps/valdi_gpt:valdi_gpt_hotreload

You should see a blank screen. If you don't, check the hotreloader for errors.

If you do see errors, check out the Getting help section.

Advanced UI topics​

Was this page helpful?
Yes
No