아래 코드에서 상태가 변경될 때 위젯의 HTML을 어떻게 다시 로드할 수 있을까요? 처음에는 상태가 none이지만, 페이지가 로드된 후에는 새로운 상태로 변경됩니다. 그러나 HTML은 클릭할 때만 변경됩니다. 상태가 업데이트될 때 자동으로 새로고침하는 방법을 알려주세요.
const h = require(“virtual-dom”).h;
api.createWidget(“my-first-widget”, {
tagName: “div.navigationBar”,
buildKey: () => ‘increment-button’,
defaultState() {
api.onPageChange((url, title) => {
name="new state"
})
return {
name: "none",
};
},
html(attrs, state) {
return h('h1',state.name)
});