You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which in the case of component creation, creates a scope (which manages the state of a component) and calls mount_in_place. Scope manages a state machine and starts in the ReadyState.
CreateComponent first advances the scope state machine from ReadyState to CreatedState and calls the create() method on a Component.
CreateComponent then calls update() which will call the view() method of a Component (via render()) and then diffs the virtual dom tree produced from the Component::view
Objectives
Need a reference to the underlying Component from VComp so that we can call view() on it to get its virtual DOM tree.
Need to create a code path for SSR that does not involve any browser APIs. Currently, those APIs are called when diffing virtual dom trees inside VDiff implementations.
Objective 1
For this part, it's important to understand how the state machine of VComp works. Its state is represented in the MountState enum. Unmounted contains a generator closure which holds the component props which is needed for creating the component.
We probably need to
add a new GeneratorType for SSR .. maybe something called GeneratorType::ServerRender
change the return type of Generator to MountState because we wouldn't want GeneratorType::ServerRender to return a Mounted because that references actual dom elements which won't exist on the server
Objective 2
We could split CreatedState::update so that we don't couple the call to render() with the mounting to the browser through VDiff::apply
The text was updated successfully, but these errors were encountered:
Problem
It's not possible to get an html string representation of a component virtual node
How Yew creates component virtual nodes
html! { <MyComponent /> }
creates aVChild
hereVChild
is transformed into aVNode
hereVChild
toVComp
happens hereHow Yew renders components
VDiff
trait to compare theVComp
to the current virtual node in the desired place in the virtual DOM treeComponent
, Yew will update the existing component. Otherwise it creates a new instance.VComp
's generator closure.mount_in_place
. Scope manages a state machine and starts in theReadyState
.CreateComponent
andMountedComponent
.CreateComponent
is all we want for static rendering and is defined here.CreateComponent
first advances the scope state machine fromReadyState
toCreatedState
and calls thecreate()
method on aComponent
.CreateComponent
then callsupdate()
which will call theview()
method of aComponent
(viarender()
) and then diffs the virtual dom tree produced from theComponent::view
Objectives
Component
fromVComp
so that we can callview()
on it to get its virtual DOM tree.VDiff
implementations.Objective 1
For this part, it's important to understand how the state machine of
VComp
works. Its state is represented in theMountState
enum.Unmounted
contains a generator closure which holds the component props which is needed for creating the component.We probably need to
GeneratorType
for SSR .. maybe something calledGeneratorType::ServerRender
Generator
toMountState
because we wouldn't wantGeneratorType::ServerRender
to return aMounted
because that references actual dom elements which won't exist on the serverObjective 2
We could splitCreatedState::update
so that we don't couple the call torender()
with the mounting to the browser throughVDiff::apply
The text was updated successfully, but these errors were encountered: