投稿時間:2023-07-15 18:10:34 RSSフィード2023-07-15 18:00 分まとめ(11件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
AWS AWSタグが付けられた新着投稿 - Qiita [AWS Q&A 365][ECR]AWSのよくある問題の毎日5選 #95 https://qiita.com/shinonome_taku/items/c980e5268a0a6ab098fc aamazonecr 2023-07-15 17:33:08
AWS AWSタグが付けられた新着投稿 - Qiita [AWS Q&A 365][ECR]Daily Five Common Questions #95 https://qiita.com/shinonome_taku/items/e5a2574887ca0b2bcdb7 featur 2023-07-15 17:30:54
Docker dockerタグが付けられた新着投稿 - Qiita 低速なイメージの中身 〜Dockerの『中間イメージ』と『レイヤー』の違い〜 https://qiita.com/ch_/items/0ca56b26f302b7728d64 exposeenvcopyet 2023-07-15 17:57:21
Azure Azureタグが付けられた新着投稿 - Qiita Azure Cloud Shell で任意のバージョンの Azure CLI を使う例 https://qiita.com/mnrst/items/8b86ec1d6ae5852ca4e1 azurecli 2023-07-15 17:38:50
海外TECH MakeUseOf 7 Free and Minimalist Meditation Sites for Quick Mindfulness and Stress Relief https://www.makeuseof.com/free-minimalist-meditation-sites-for-mindfulness-stress-relief/ relief 2023-07-15 08:30:18
海外TECH DEV Community Unsafe 'PropsWithChildren' Utility type in React TypeScript App https://dev.to/maafaishal/unsafe-propswithchildren-utility-type-in-react-typescript-app-3bd3 Unsafe x PropsWithChildren x Utility type in React TypeScript AppAs React developer we are all familiar with creating components whether as classes or functions to add features to web pages One of the common cases in React is a component that has JSX Children When you want to nest content inside a JSX tag the parent component will receive that content in a prop called children For instance the Modal component below will receive children prop set to and render it in a wrapper div React JavaScriptfunction Modal props const children props return lt div className modal gt children lt div gt function Page return lt Modal gt lt title gt Submit Form lt title gt lt form onSubmit handleSubmit gt lt input type text gt lt input type submit gt lt form gt lt Modal gt If it wants to be converted to TypeScript most of developers use PropsWithChildren utility type from types react package React TypeScriptimport type PropsWithChildren from react props children React ReactNode function Modal props PropsWithChildren lt gt const children props return lt div className modal gt children lt div gt function Page return lt Modal gt lt title gt Submit Form lt title gt lt form onSubmit handleSubmit gt lt input type text gt lt input type submit gt lt form gt lt Modal gt It helps TypeScript understand that the component should have the children prop ProblemsSounds good so far right But here s where things get weird Let me highlight the code props children React ReactNode Unexpected import type PropsWithChildren from react props children React ReactNode function Modal props PropsWithChildren lt gt const children props return lt div className card gt children lt div gt function Page return lt Modal gt The children is supposed to be required That means we must provide children when using Modal component But guess what It becomes optional Rendering Modal component without children is now even possible Let s check what s inside PropsWithChildren Here it is referring to types react Github type PropsWithChildren lt P unknown gt P amp children ReactNode undefined Turns out the culprit is types react itself This little bug might not seem like a big deal at first but trust me it can cause some serious problems and mess up with your business logic And the worst part Neither React nor TypeScript will show any errors leaving you scratching your head when things go wrong ‍ SolutionsSo what can we do about this Let s explore some solutions Never Trust and Always Check third party codeAs you know earlier the culprit is types react itself This is not the first time Previously developers had a problem with React FC Some of them even posted about it TypeScript React Why I don t use React FCWhy you probably shouldn t use React FC to type your React componentsWhy You Should Probably Think Twice About Using React FCAll those fancy magic codes will eventually lose their magic over time So you should always check what s behind the code Create your own Utility typeSince the PropsWithChildren from types react is not that hard why don t you create it yourself type PropsWithChildren lt P unknown gt P amp children ReactNode PropsWithChildren utility type is for components that have children prop and it s required type PropsWithOptionalChildren lt P unknown gt P amp children ReactNode PropsWithOptionalChildren utility type is for components that have children prop but it s optional It looks reliable and unambiguous ConclusionRemember these tips and you ll save yourself from headaches I hope these tips come in handy for your projects 2023-07-15 08:15:09
ニュース BBC News - Home Just Stop Oil protesters interrupt the Proms https://www.bbc.co.uk/news/uk-66207576?at_medium=RSS&at_campaign=KARANGA albert 2023-07-15 08:07:36
ニュース BBC News - Home Extra energy bill scheme was staggering failure, says MP https://www.bbc.co.uk/news/business-66203677?at_medium=RSS&at_campaign=KARANGA energy 2023-07-15 08:47:24
ニュース BBC News - Home Declan Rice says 'tough' to leave West Ham with Arsenal move agreed https://www.bbc.co.uk/sport/football/66209874?at_medium=RSS&at_campaign=KARANGA Declan Rice says x tough x to leave West Ham with Arsenal move agreedDeclan Rice says it has been a tough decision to leave West Ham but it has only ever been about my ambition to play at the very highest level of the game 2023-07-15 08:10:12
ニュース BBC News - Home 'I've lived in the same house for 105 years' https://www.bbc.co.uk/news/uk-england-nottinghamshire-66204337?at_medium=RSS&at_campaign=KARANGA allcock 2023-07-15 08:15:45
海外TECH reddit Friends, A-to-Z – ‘at’ https://www.reddit.com/r/howyoudoin/comments/1506b0j/friends_atoz_at/ Friends A to Z at All together now Smelly cat smelly cat what are they feeding you Only seven left to go Here s our alphabet A Asleep B Bing C Crapbag D Denise DENISE E EEEEEEEEeeeeeeEEEEEEEEEEeeeeEEE F FRONT AND BACK G Gum would be perfection H How you doin I In London J Joey doesn t share food K Kidney Stones L Look at me I m Chandler Could I be wearing any more clothes M My sandwich My sandwich N Nestle Tool ouse Nestle TOLLhouse O Oh My God P Pivot Pivot Piv aht Q Queen Rachel does whatever she wants in little Rachel land hair flip R Regina Phalange S Smelly cat smelly cat what are they feeding you Gimme a T submitted by u rhubarbeyes to r howyoudoin link comments 2023-07-15 08:27:16

コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)