我想從回調中的父組件中設置一個子組件的實例變量。使用調試器,我可以看到實例變量在回調中設置正確,但在渲染子組件時,子組件不反映所做的更改。從另一個組件修改組件的狀態
那麼,從海邊的另一個組件修改組件的狀態是不合法還是我在做其他錯誤?
示例代碼:
MyParentComponent>> initialize
super initialize.
child := MyChildComponent new.
MyParentComponent>> renderContentOn: html
html render: child.
html anchor
callback: [
child property: 'Something'.
] ; with 'Navigate'.
MyParentComponent>> children
^Array with: child
這將有助於發佈代碼來舉例說明問題。 –
我已經添加了一部分代碼。 MyChildComponent有一個實例變量'property',它的值用於渲染。 – raphonic