0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

CustomElementでSlotの変更がリロードで反映されない

Posted at

はじめに

CustomElementを作成したのですが、うまくいかなかったのでまとめます
地味に引っかかる人が多いのではないかと思います

問題

index.html
  <body>
    <script src="./src/index.tsx" type="module"></script>
    <div>
      <sample-element>
        <span slot="test-msg"><div>テストメッセージ</div></span>
      </sample-element>
    </div>
  </body>
index.tsx
const SampleElement: FC = () => {
  return (
    <>
      <slot name="test-msg"></slot>
    </>
  );
};

これでテストメッセージという文字が表示されています

image.png

そこからテストメッセージの文字を変えます

        <span slot="test-msg"><div>テストメッセージ!!!</div></span>

しかし画面の文字は変わらず、リロードしてもハードリロードもだめでした

解決方法

Developer ToolsのNetworkFast3Gになっていたのが問題でした

image.png

No throttlingにすることで更新されるようになりました

image.png

おわりに

たしかにスロットリングと書いてあるのでなにか関係しているみたいです

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?