Examples
Practical examples। Live demos।
कोई example चुनिए और फ़ुल-स्क्रीन में खोलिए: live preview और source code साथ-साथ।
कोई example चुनिए और फ़ुल-स्क्रीन में खोलिए: live preview और source code साथ-साथ।
नाम बदलिए। static text element बनते समय ही तय हो गया था, जबकि dynamic text हर update() पर दोबारा चलता है। forceUpdate() पूरा tree दोबारा बनाता है, इसलिए static text भी update हो जाता है।
static: Hello, Alice
dynamic: Hello, Alice
import 'nuclo' let name = 'Alice' let host: Element | undefined const Greeting = () => div( input({ value: () => name, onInput: (e) => { name = e.currentTarget.value; update() }, }), p('static: ', `Hello, ${name}`), // built once p('dynamic: ', () => `Hello, ${name}`), // runs on every update() ) export const App = () => div( div({ onMount: (el) => { host = el as unknown as Element } }, Greeting()), // Calls Greeting() again and patches the same nodes: the static text // catches up. The explicit form rebuilds only this tree. button('forceUpdate()', { onClick: () => { if (host) forceUpdate(Greeting(), host) }, }), )