今日の忙しい:uiライブラリを作成するときに注意しなければならないこと(共通)
2786 ワード
ブラウザオブジェクト(
サーバ上では以下のように
docuemnt
、navigator
など)を防止するにはサーバ上では以下のように
typeof docuemnt === 'undefined'
typeof navigator === 'undefined'
typeof window === 'undefined'
次のhookを作成して使用します.import React from 'react';
const useBrowserEffect: typeof React.useEffect = (effect, deps = []) => {
React.useEffect(() => {
if (typeof document !== 'undefined') {
effect();
}
}, [...deps]);
};
export default useBrowserEffect;
Reference
この問題について(今日の忙しい:uiライブラリを作成するときに注意しなければならないこと(共通)), 我々は、より多くの情報をここで見つけました https://velog.io/@gtah2yk/오늘의-뻘-ui-라이브러리-만들-때-신경써야할-것유니버셜テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol