IT |
気になる、記になる… |
DJI、スマートフォンジンバル「Osmo Mobile 6」の新色プラチナグレーを発売 − 価格も少し値下げ |
https://taisy0.com/2023/07/05/173663.html
|
osmomobile |
2023-07-05 12:40:55 |
IT |
気になる、記になる… |
「Nothing ear (2)」のブラックモデルの製品画像が流出 |
https://taisy0.com/2023/07/05/173658.html
|
nothing |
2023-07-05 12:12:40 |
IT |
ITmedia 総合記事一覧 |
[ITmedia News] 「推しの子」有馬かなデザインの「重曹ちゃん」ホントに発売 エイプリルフール企画から実現 |
https://www.itmedia.co.jp/news/articles/2307/05/news181.html
|
itmedia |
2023-07-05 21:42:00 |
IT |
ITmedia 総合記事一覧 |
[ITmedia Mobile] Twitterの閲覧制限、事前告知がなかった理由は? X社がビジネス向けのWebページで釈明 |
https://www.itmedia.co.jp/mobile/articles/2307/05/news182.html
|
itmediamobiletwitter |
2023-07-05 21:40:00 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
機械学習モデルの解析に新たな風を! Phoenixを使ってみる |
https://qiita.com/sergicalsix/items/3de5116aa23922bd9bcf
|
phoenix |
2023-07-05 21:49:16 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
gspreadを利用してスクレイピングした内容をスプレッドシートに自動入力 |
https://qiita.com/spicy_pse/items/e6619fe64a4e1e5780e0
|
gspread |
2023-07-05 21:36:16 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
pako.jsで圧縮したgzipバイナリをpythonで展開する |
https://qiita.com/masakun1150/items/4e9626c0a05e4a0aca87
|
pakojs |
2023-07-05 21:21:33 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
pako.jsで圧縮したgzipバイナリをpythonで展開する |
https://qiita.com/masakun1150/items/4e9626c0a05e4a0aca87
|
pakojs |
2023-07-05 21:21:33 |
Azure |
Azureタグが付けられた新着投稿 - Qiita |
【AZ-900】いろいろなコンピューティングサービス |
https://qiita.com/mei2678/items/1eb472f3c591b2524aaf
|
tualmachinesazureappserv |
2023-07-05 21:46:47 |
Azure |
Azureタグが付けられた新着投稿 - Qiita |
【AZ-900】Azureの基本的構造 |
https://qiita.com/mei2678/items/d75a59c315c476ea6477
|
azure |
2023-07-05 21:05:04 |
技術ブログ |
Developers.IO |
JFrog Artifactory/Xray/PipelinesのAWS公式ワークショップを動かしてみた |
https://dev.classmethod.jp/articles/202307-jfrog-workshop/
|
gartifactoryxraypipelines |
2023-07-05 12:07:20 |
海外TECH |
DEV Community |
Build a guestbook from the 2000s with React Server Components and Server Actions |
https://dev.to/scastiel/intro-to-react-server-components-and-actions-with-nextjs-j1j
|
Build a guestbook from the s with React Server Components and Server ActionsReact is living something these days Although it was created as a client UI library it can now be used to generate almost everything from the server And we get a lot from this change especially when coupled with Next js In this short tutorial we ll use React Server Components and Server Actions to build something from the early s a guestbook I bootstrapped a Next js app with TypeScript and the app router As I don t want to care about the CSS I used Water css And to store the messages I went with Vercel KV which may not be the right tool for this kind of use case but is plenty enough for the purpose of this post The complete source code of the demo project is available on GitHub Fetching the messages from a Server ComponentLet s start with displaying the existing messages With a classic React component we d have to declare a local state perform a fetch request in a useEffect etc With Next js server side rendering we could declare a getServerSideProps function to fetch the messages first With server components we can fetch the messages from the component itself export async function MessageList const messages await fetchMessages return lt gt lt h gt Last Messages lt h gt messages map id name content date gt lt blockquote key id gt lt div gt content lt div gt lt small gt name formatDate date lt small gt lt blockquote gt lt gt Looks odd to you It should The component is declared async and fetches data from its body without any useEffect This is what server components let us do As a server component can be rendered only on the server we can perform asynchronous operations such as querying a database making HTTP requests or even read from the filesystem As a consequence notice how the component is easy to read even by someone who s not as familiar with React as you are We fetch the data and we display it That s it What if fetching the messages takes a few seconds Does it mean that the page will take that much time to load Fortunately no We can take advantage of React s Suspense to display a nice loading message while the component is still fetching the data In the page displaying messages we can wrap our MessageList component with Suspense with a fallback message export default function MessagesPage return lt gt lt Suspense fallback lt p gt Loading messages… lt p gt gt lt MessageList gt lt Suspense gt lt gt For a deeper dive in Server Components and Suspense have a look at my previous post Display a view counter on your blog with React Server Components So this is how we can read data from a server component but is there something similar for writing data so we can post new messages as easily Submitting forms with Server ActionsServer components let us fetch data without having to set up a flow with useEffect We can do something similar to submit data from a form thanks to Server Actions Let s start with this basic form export function MessageForm return lt form gt lt h gt New Message lt h gt lt label htmlFor name gt Your name lt label gt lt input type text id name name name required minLength gt lt label htmlFor content gt Your message lt label gt lt textarea id content name content required minLength gt lt button type submit gt Send lt button gt lt form gt As you can see there is nothing fancy here two fields a button and some validation attributes To submit this form we usually have two options use the action attribute to use an API endpoint handling the form data manually make a fetch request to call this API endpoint In the first scenario the page would reload when the user submits the form which is something we may want to avoid The second scenario is the one we tend to prefer in React apps but is a bit more complex to set up With server actions we can get the best of both worlds We can create a function that will be called on the server when the form is submitted async function submitMessageForm formData FormData use server await postMessage content formData get content name formData get name By adding use server in the function body we declare it as a server action We can then associate it with the form by using the action attribute return lt form action submitMessageForm gt Note to use server actions in a Next js project you need to enable them in your next config js file experimental serverActions true What about form data validation We declared some validation attributes on the form itself but as always it doesn t prevent us of validating the data on the server Validation example using a Zod schemaconst message formDataSchema parse content formData get content name formData get name await postMessage message Finally we can make another nice improvement to our server action By adding a call to Next js revalidatePath function we can tell the app that some resources need to be reloaded Said differently we can refresh the messages displayed on the page after we created the new one await postMessage message revalidatePath assuming the messages are displayed at rootHere is what our form looks like now We can see that the message is added to the list without needing to refresh the page But the form is not reset after being submitted which can be a little annoying Additionally you probably noticed that the form validation is quite minimalist we use the HTML validation attributes for the client validation and a Zod schema for the server one How nice would it be to use the same validation on both sides Good news it is not because we use server actions that we can t use cool client features to handle forms Let s see how Improving the form with client featuresSo far our form doesn t use any client feature Actually it is still a server component that can be used with JavaScript disabled To add some cool features to it let s start by making it a client component This means adding the use client directive at the top of the file moving the server action to a new actions ts file as we can t declare server actions in client files To improve our form I will use the react hook form library Here is how to use it on our form export function MessageForm const register handleSubmit useForm lt MessageFormData gt shouldUseNativeValidation true resolver zodResolver formDataSchema return lt form onSubmit handleSubmit data gt submitMessageForm data gt lt h gt New Message lt h gt lt label htmlFor name gt Your name lt label gt lt input type text id name register name gt lt label htmlFor content gt Your message lt label gt lt textarea id content register content gt lt button type submit gt Send lt button gt lt form gt By using register on each field of the form we let the library handle the form local state and validation Note that we use the existing Zod schema to define the validation rules thanks to the Zod resolver for react hook form by setting shouldUseNativeValidation true we rely on the browser API to display the validation errors in the form a feature I love We need to change a bit the server action to comply with the new way data is sent by react hook form a plain object instead of a FormData object export async function submitMessageForm formData MessageFormData formDataSchema parse formData await postMessage formData revalidatePath Important note we may think that because we call the function directly from the form we don t have to care about validating the form data the parameter We do need to care about it Although Next js handles it for us there is still an HTTP request made to an API endpoint to call the server action And it is very easy to make this call manually with invalid data This is why we still check that the data is conform with the Zod schema at the top of the function even if TypeScript lets us think the data is already a MessageFormData But at least we can use the same validation logic both on the client and the server So now we handle the validation a bit better We can still even improve the form First let s reset the form after it is submitted react hook form provides a reset function that we can call right after calling the server action which returns a promise export function MessageForm const reset useForm lt MessageFormData gt return lt form onSubmit handleSubmit async data gt await submitMessageForm data reset gt Final improvement if the submission takes a couple of seconds it is a good practice to tell the user the form is being submitted and prevent them from clicking the submit button again And again react hook form provides the information we need an isSubmitting flag export function MessageForm const formState isSubmitting useForm lt MessageFormData gt return lt button type submit disabled isSubmitting gt isSubmitting Sending… Send lt button gt Now thanks to client features we handle validation the same way on the client and the server we tell the user the form is being submitted and reset the form when it is done Tiny improvements but great for the user experience as well as the developer experience Here is how our final guestbook looks like To be fair these last improvements we made come with a cost it isn t possible anymore to use the form without having JavaScript enabled I ll let you decide whether it is worth it or not So in the end what do Server Actions offer us and how do they compare to Server Components Server Components let us fetch data without creating an additional endpoint and calling it from the client Server Actions let us post data without creating an additional endpoint and calling it from the client What I love about server component and actions is that they hide some logic without making anything magic and make the code way easier to understand To me they even make it easier to learn React a point of view I developed in my post A better learning path for React with server components It s a bit early to say they will change the way we build web apps on the long term but I would take that bet |
2023-07-05 12:51:05 |
Apple |
AppleInsider - Frontpage News |
Apple Vision Pro research and early work was hidden in plain sight |
https://appleinsider.com/articles/23/07/05/apple-vision-pro-research-and-early-work-was-hidden-in-plain-sight?utm_medium=rss
|
Apple Vision Pro research and early work was hidden in plain sightFrom patents for smart rings to ones for projecting a Mac s desktop out onto the wall Apple has been hiding Apple Vision Pro in plain sight for years Why didn t we see what was right in front of our faces Over the last decade there must have been hundreds of Apple patents and patent applications that were immediately and indisputably concerned with headsets They even include the word headset Read more |
2023-07-05 12:19:19 |
Apple |
AppleInsider - Frontpage News |
Firefox ending support for macOS Mojave and earlier versions |
https://appleinsider.com/articles/23/07/04/firefox-ending-support-for-macos-mojave-and-earlier-versions?utm_medium=rss
|
Firefox ending support for macOS Mojave and earlier versionsOn Tuesday Mozilla creator of the web browser Firefox announced that macOS Mojave and earlier won t get major updates past version ーbut security updates will keep coming for a year The release notes state that users running macOS and will be migrated to the ESR version of Firefox so that they continue to receive important security updates According to the Mozilla Wiki Firefox is set to release in August It will require users to be running macOS Catalina or newer Read more |
2023-07-05 12:22:40 |
海外TECH |
Engadget |
Meta's Threads is already showing conversations on the web |
https://www.engadget.com/metas-threads-is-already-showing-conversations-on-the-web-120453471.html?src=rss
|
Meta x s Threads is already showing conversations on the webWith Twitter seemingly on its last legs it doesn t come as a big surprise that other social media giants would want to capitalize on the void Meta is launching Threads which allows users to write and comment on posts much in the same way as Twitter Now we have a first look at how Threads will operate thanks to early users profiles showing up on its website Instagram head Adam Mosseri has used his first few posts to share more about Thread s purpose and features including an image demonstrating how to limit replies quot We have lots of work to do but we re looking to build an open civil place for people to have conversations quot Mosseri shared in his first post Users will also be able to Repost instead of Retweet individual Threads as well as share them Threads will eventually include Fediverse integration allowing users to follow and interact with users on other services like Mastodon Mosseri confirmed that Meta is quot committed quot to supporting the ActivityPub protocol but the company wasn t able to finish the integration before launch quot You may one day end up leaving Threads or hopefully not end up de platformed quot the Instagram chief explained quot If that ever happens you should be able to take your audience with you to another server Being open can enable that quot ThreadsMeta employees like CEO Mark Zuckerberg and Mosseri have been posting alongside celebs like Shakira and Gordon Ramsey and a range of influencers who were given first access to Threads The limited number of initial users reflects in current follower counts with most profiles only having a few hundred and Zuckerberg and Mosseri at only a couple thousand Threads will be available on the web and for download on the App Store and Google Play Store starting the morning of July th in the US and UK It won t be available across the rest of Europe yet though likely due to stricter EU data privacy rules In the meantime Meta employees aren t averse to patting themselves on the back while taking a dig at Twitter as Meta product designer Peter Franko did in his first post on the site ThreadsThis article originally appeared on Engadget at |
2023-07-05 12:04:53 |
海外科学 |
NYT > Science |
Lewis Branscomb, Champion of Science Across Fields, Dies at 96 |
https://www.nytimes.com/2023/07/04/technology/lewis-branscomb-dead.html
|
Lewis Branscomb Champion of Science Across Fields Dies at He led scientific advances at IBM and within the federal government during a career that spanned the space race and the dawn of the internet |
2023-07-05 12:55:14 |
ニュース |
BBC News - Home |
Train firms plan mass closures of ticket offices |
https://www.bbc.co.uk/news/business-66097850?at_medium=RSS&at_campaign=KARANGA
|
england |
2023-07-05 12:03:24 |
ニュース |
BBC News - Home |
Water bills expected to rise, says regulator |
https://www.bbc.co.uk/news/business-66106909?at_medium=RSS&at_campaign=KARANGA
|
ofwat |
2023-07-05 12:02:08 |
ニュース |
BBC News - Home |
Windsor Castle treason arrest man inspired by Star Wars |
https://www.bbc.co.uk/news/uk-england-berkshire-66101070?at_medium=RSS&at_campaign=KARANGA
|
christmas |
2023-07-05 12:32:28 |
ニュース |
BBC News - Home |
Ukraine plane: Iran facing legal action over downing of Flight PS752 |
https://www.bbc.co.uk/news/world-middle-east-66110345?at_medium=RSS&at_campaign=KARANGA
|
action |
2023-07-05 12:13:57 |
ニュース |
BBC News - Home |
BBC reports from inside Jenin refugee camp after Israeli assault |
https://www.bbc.co.uk/news/world-middle-east-66107393?at_medium=RSS&at_campaign=KARANGA
|
assaultthe |
2023-07-05 12:46:38 |
ニュース |
BBC News - Home |
Naturalist Steve Backshall: State of our rivers is source of shame |
https://www.bbc.co.uk/news/uk-england-berkshire-66110367?at_medium=RSS&at_campaign=KARANGA
|
great |
2023-07-05 12:23:34 |
ニュース |
Newsweek |
韓国・済州島ショッピングセンターの天井が崩落 手抜き工事でなく人災との指摘も |
https://www.newsweekjapan.jp/stories/world/2023/07/post-102105.php
|
事故が起きたこのショッピングセンターでは、済州市が商店街施設のリニューアル化事業をするため、天井にエアコンを設置してからわずか週間ほどで事故が起きたという。 |
2023-07-05 21:00:59 |
仮想通貨 |
BITPRESS(ビットプレス) |
ブロックチェーン推進協会(BCCC)、2023年7月に「ステーブルコイン普及推進部会」を新設 |
https://bitpress.jp/count2/3_17_13661
|
部会 |
2023-07-05 21:51:43 |
海外TECH |
reddit |
DRX vs. T1 / LCK 2023 Summer - Week 5 / Post-Match Discussion |
https://www.reddit.com/r/leagueoflegends/comments/14r8oee/drx_vs_t1_lck_2023_summer_week_5_postmatch/
|
DRX vs T LCK Summer Week Post Match DiscussionLCK SUMMER Official page Leaguepedia Liquipedia Eventvods com New to LoL DRX T Poby subbing in for Faker due to injury DRX Leaguepedia Liquipedia Website Twitter Facebook YouTube Subreddit T Leaguepedia Liquipedia Website Twitter Facebook YouTube MATCH DRX vs T Winner DRX in m POG Rascal Damage Graph Runes Bans Bans G K T D B DRX vi viego poppy milio varus k H HT I B I B T tristana leblanc neeko ashe draven k CT H DRX vs T Rascal jax TOP renekton Zeus Juhan sejuani JNG maokai Oner FATE azir MID jayce Poby Paduck xayah BOT kaisa Gumayusi BeryL rell SUP alistar Keria MATCH T vs DRX Winner DRX in m POG FATE Damage Graph Runes Bans Bans G K T D B T sejuani tristana maokai alistar rakan k H M B DRX vi viego poppy khazix leesin k HT H CT CT T vs DRX Zeus gragas TOP jax Rascal Oner wukong JNG nocturne Juhan Poby annie MID leblanc FATE Gumayusi draven BOT varus Paduck Keria rell SUP heimerdinger BeryL Patch This thread was created by the Post Match Team submitted by u adzr to r leagueoflegends link comments |
2023-07-05 12:02:00 |
コメント
コメントを投稿