IT |
ITmedia 総合記事一覧 |
[ITmedia News] PayPayの携帯料金合算チャージ、「手数料2.5%上乗せ」を延期 |
https://www.itmedia.co.jp/news/articles/2306/14/news135.html
|
itmedianewspaypay |
2023-06-14 13:40:00 |
IT |
ITmedia 総合記事一覧 |
[ITmedia News] 1000人に聞いた「昨年、最も課金したゲームは」 3位「FGO」、2位「ツムツム」、1位は? |
https://www.itmedia.co.jp/news/articles/2306/14/news137.html
|
itmedia |
2023-06-14 13:38:00 |
IT |
ITmedia 総合記事一覧 |
[ITmedia ビジネスオンライン] 20年超の荒れ地が一転、地域のシンボルに 大阪・泉南ロングパーク |
https://www.itmedia.co.jp/business/articles/2306/14/news136.html
|
itmedia |
2023-06-14 13:36:00 |
IT |
ITmedia 総合記事一覧 |
[ITmedia News] 日本俳優連合が“生成AI”に提言 「新たな法律の制定を強く望む」 声の肖像権確立など求める |
https://www.itmedia.co.jp/news/articles/2306/14/news133.html
|
itmedia |
2023-06-14 13:30:00 |
IT |
ITmedia 総合記事一覧 |
[ITmedia PC USER] MINISFORUM、第13世代Core i7を採用したミニデスクトップPC |
https://www.itmedia.co.jp/pcuser/articles/2306/14/news132.html
|
corei |
2023-06-14 13:18:00 |
AWS |
AWS Japan Blog |
AWS Week in Review – SQS のための DLQ 再処理の自動化、Lambda による Ruby 3.2 のサポートなど – 2023 年 6 月 12 日 |
https://aws.amazon.com/jp/blogs/news/aws-week-in-review-automate-dlq-redrive-for-sqs-lambda-supports-ruby-3-2-and-more-june-12-2023/
|
awssummitmad |
2023-06-14 04:45:27 |
AWS |
AWS - Webinar Channel |
Analytics in 15: Build Apache Spark Apps and Integrate Them with Redshift |
https://www.youtube.com/watch?v=ua_HR9OyhbQ
|
Analytics in Build Apache Spark Apps and Integrate Them with RedshiftThe Amazon Redshift integration for Apache Spark makes it easy to build and run Spark applications on Amazon Redshift If you are using Amazon EMR AWS Glue and Amazon SageMaker you can quickly build Apache Spark applications in a variety of languages that read from and write to your Amazon Redshift data warehouse without compromising performance or transactional consistency |
2023-06-14 04:23:11 |
AWS |
lambdaタグが付けられた新着投稿 - Qiita |
CDKでLambdaレイヤーを作成して使用する |
https://qiita.com/haruki-lo-shelon/items/72b7308be3bb6bbaad69
|
fastapi |
2023-06-14 13:03:06 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
AIイラスト|自分好みのキャラをつくるときのプロンプト備忘録(※順次更新) |
https://qiita.com/TAKANORI_IMAI/items/6a3162b1de46ff298ad1
|
pythonstablediffusion |
2023-06-14 13:30:26 |
Ruby |
Rubyタグが付けられた新着投稿 - Qiita |
RubyでcsvファイルをParquet形式に変換 |
https://qiita.com/kojix2/items/40d2ae783bba4f941f86
|
requirepolarsdf |
2023-06-14 13:49:17 |
Ruby |
Rubyタグが付けられた新着投稿 - Qiita |
Rails6系 Herokuデプロイ時トラブルシューティング(忘備録) |
https://qiita.com/_OnO_/items/8435cd51c246fa563b45
|
heroku |
2023-06-14 13:01:17 |
golang |
Goタグが付けられた新着投稿 - Qiita |
Go Conference 2023 に参加しました! |
https://qiita.com/_otakakot_/items/e31b1ca4dbcfe2250821
|
https |
2023-06-14 13:52:37 |
技術ブログ |
Developers.IO |
バージニア北部リージョンで障害が発生するとヒヤヒヤする理由 |
https://dev.classmethod.jp/articles/us-east-1-global/
|
ohumanlaborisnohumanerror |
2023-06-14 04:37:45 |
技術ブログ |
Developers.IO |
ブログ記事の検索ボットを作ってみた |
https://dev.classmethod.jp/articles/implement-devio-articles-search-bot/
|
largelanguagemodel |
2023-06-14 04:30:22 |
海外TECH |
DEV Community |
A Comprehensive Guide to React Hooks: Simplifying State and Side Effects |
https://dev.to/kingsley/a-comprehensive-guide-to-react-hooks-simplifying-state-and-side-effects-39f3
|
A Comprehensive Guide to React Hooks Simplifying State and Side Effects Introduction to React Hooks React Hooks have revolutionized the way we write React components by providing a simpler and more elegant approach to managing state and handling side effects In this article we will explore the core hooks in React and dive into custom hooks advanced hook patterns and best practices Let s get started Benefits of using Hooks over class componentsBefore the introduction of React Hooks managing state and side effects in functional components was challenging Class components required complex lifecycle methods and often led to verbose and convoluted code React Hooks solve these problems by offering a more intuitive and functional approach With Hooks we can write cleaner more readable code and enjoy benefits such as improved reusability code organization and performance optimizations Understanding the Core Hooks useState Hook The useState hook allows us to introduce stateful logic into functional components It takes an initial state value as an argument and returns an array with the current state value and a function to update the state Let s see an example of creating a counter component using useState import React useState from react function Counter const count setCount useState return lt div gt lt p gt Count count lt p gt lt button onClick gt setCount count gt Increment lt button gt lt div gt In the above code we initialize the count state to using useState The count value is displayed and the setCount function is used to update the count when the button is clicked useEffect HookThe useEffect hook enables us to perform side effects in functional components such as fetching data from an API subscribing to events or manipulating the DOM It accepts a callback function and an optional dependency array to control when the effect runs Let s see an example of fetching data from an API using useEffect import React useState useEffect from react function DataFetcher const data setData useState useEffect gt fetch then response gt response json then data gt setData data return lt div gt data map item gt lt p key item id gt item name lt p gt lt div gt In this code we use useEffect to fetch data from an API when the component mounts The fetched data is stored in the state using the setData function and it is rendered in the component useContext HookThe useContext hook provides a way to access shared state or data without prop drilling It allows us to create a context and consume it in any component within the context provider Let s see an example of creating a theme switching component using useContext import React useContext from react const ThemeContext React createContext light function ThemeSwitcher const theme useContext ThemeContext return lt div gt lt p gt Current theme theme lt p gt lt button onClick gt console log Switch theme gt Switch Theme lt button gt lt div gt In the code above we create a ThemeContext using React createContext and provide a default value of light The useContext hook is used in the ThemeSwitcher component to access the current theme value When the button is clicked it triggers a theme switch action Custom Hooks Reusability and Abstraction Custom hooks are a powerful concept in React that allows us to extract and share stateful and reusable logic across multiple components They provide a way to abstract complex logic into reusable functions By creating custom hooks we can enhance code reusability and make our components more modular and maintainable Building a form validation hook Let s build a custom hook for a form validation The hook will handle the validation logic and return the validation state and functions to update the form values and trigger validation useFormValidation Custom Hookimport React useState from react function useFormValidation initialState validate const values setValues useState initialState const errors setErrors useState const isSubmitting setSubmitting useState false const handleChange event gt setValues values event target name event target value const handleSubmit event gt event preventDefault setErrors validate values setSubmitting true return values errors isSubmitting handleChange handleSubmit Explanation The useFormValidation custom hook handles the state and logic for form validation It takes in initialState which is an object representing the initial form values and validate which is a function for validating the form values It returns an object with values errors isSubmitting handleChange and handleSubmit values represents the current form values errors holds any validation errors for the form isSubmitting indicates whether the form is being submitted handleChange is a function that updates the form values as the user types handleSubmit is a function that handles the form submission triggers validation and sets the errors and submitting state LoginForm Componentfunction validateLoginForm values let errors if values email errors email Email is required if values password errors password Password is required else if values password length lt errors password Password must be at least characters long return errors function LoginForm const values errors isSubmitting handleChange handleSubmit useFormValidation email password validateLoginForm return lt form onSubmit handleSubmit gt lt div gt lt label htmlFor email gt Email lt label gt lt input type email id email name email value values email onChange handleChange gt errors email amp amp lt span gt errors email lt span gt lt div gt lt div gt lt label htmlFor password gt Password lt label gt lt input type password id password name password value values password onChange handleChange gt errors password amp amp lt span gt errors password lt span gt lt div gt lt button type submit disabled isSubmitting gt Submit lt button gt lt form gt export default LoginForm Explanation The LoginForm component utilizes the useFormValidation custom hook to handle the form s state and validation It also includes an example validation function validateLoginForm which validates the email and password fields Inside the component we destructure the values errors isSubmitting handleChange and handleSubmit from the useFormValidation hook These values and functions are then used within the JSX to render the form Advanced Hook Patterns useReducer HookThe useReducer hook is an alternative to useState when managing more complex state that involves multiple actions It follows the Redux pattern of managing state with reducers and actions Let s see an example of implementing a todo list using useReducer import React useReducer from react function todoReducer state action switch action type case ADD TODO return state id Date now text action payload completed false case TOGGLE TODO return state map todo gt todo id action payload todo completed todo completed todo case REMOVE TODO return state filter todo gt todo id action payload default return state function TodoList const todos dispatch useReducer todoReducer const handleAddTodo gt const todoText Get todo text from input field dispatch type ADD TODO payload todoText return lt div gt lt input type text placeholder Enter todo gt lt button onClick handleAddTodo gt Add Todo lt button gt lt ul gt todos map todo gt lt li key todo id gt lt span gt todo text lt span gt lt button onClick gt dispatch type TOGGLE TODO payload todo id gt todo completed Mark Incomplete Mark Complete lt button gt lt button onClick gt dispatch type REMOVE TODO payload todo id gt Remove lt button gt lt li gt lt ul gt lt div gt In this example we have a todoReducer function that takes in the current state and an action and based on the action type it performs the necessary updates to the state The reducer function handles three types of actions adding a new todo toggling the completion status of a todo and removing a todo The TodoList component utilizes the useReducer hook by calling it with the todoReducer function and an initial state of an empty array The hook returns the current state todos and a dispatch function that we use to send actions to the reducer The handleAddTodo function is called when the Add Todo button is clicked It retrieves the todo text from an input field which is not included in this code snippet and dispatches an action of type ADD TODO with the payload as the todo text The reducer function then adds a new todo object to the state array including an auto generated ID the todo text and a default completion status of false The TodoList component renders an input field and a button for adding new todos Below that it renders a list of todos using the todos map function Each todo is rendered as an lt li gt element with its text displayed Additionally there are two buttons for each todo one for toggling the completion status and another for removing the todo When these buttons are clicked corresponding actions are dispatched to the reducer to update the state accordingly useRef HookAccessing and persisting values across renders The useRef hook provides a way to persist values across renders without triggering a re render It can also be used to access DOM elements directly Let s see an example of implementing an input field with useRef import React useRef from react function InputWithFocus const inputRef useRef null const handleClick gt inputRef current focus return lt div gt lt input ref inputRef type text gt lt button onClick handleClick gt Focus Input lt button gt lt div gt In this code the inputRef is created using useRef and assigned to the input element s ref attribute When the button is clicked the handleClick function is triggered which focuses the input element using the ref s current property ConclusionReact Hooks have transformed the way we write React components offering a more streamlined and functional approach to managing state and handling side effects By leveraging core hooks like useState useEffect and useContext we can simplify our code and enhance reusability Additionally custom hooks and advanced hook patterns like useReducer and useRef provide powerful tools for building complex and optimized components As you embark on your React journey I encourage you to explore and experiment with React Hooks in your projects Their flexibility simplicity and performance benefits will undoubtedly elevate your development experience Happy coding |
2023-06-14 04:30:56 |
海外TECH |
DEV Community |
It's time to replace your axios |
https://dev.to/coderhu/its-time-to-replace-your-axios-143p
|
It x s time to replace your axiosAxios is a Promise based HTTP client with a weekly npm download volume of million If we go back to years ago the promise style request tool is a great innovation It solves the problem of cumbersome requests The age of not so high can be said to be the best But with the passage of time Axios began to fall behind in terms of development efficiency and performance Now it is In the face of increasingly complex requirements what we need is a more innovative and leading request tool and promise style request tools can only be called traditional if you want to stay at the forefront of rapid development then please read on First of all I want to declare that I am really not a headline party Next I will expose the inability of axios in some aspects over time and recommend a new one which is more modern and innovative than axios The request tool is for you it is lightweight request strategy library alova Next let s look at the weaknesses of Promise style request tools axios Separated from frameworks such as React and VueNow front end UI frameworks such as React and Vue are almost indispensable for the front end Axios cannot be deeply bound to the state of these frameworks and developers need to maintain them by themselves resulting in low development efficiency Does nothing in terms of performanceIt is and the application is already several orders of magnitude more complicated than the application years ago and the requirements for requests are getting higher and higher to ensure the performance requirements of the page Axios does nothing in this regard such as frequent repeated requests Initiate multiple identical requests at the same time etc Bloated volumeAccording to bundlephobia the volume of axios in the compressed state is kb see the figure belowlink here The Ts type definition of the response data is confusingWhen using axios you may often write like this Create an axios instanceconst inst axios create baseURL return data in the response interceptorinst interceptors response use response gt if response status return response data throw new Error response status interface Resp id number inst get lt Resp gt xxx then result gt The type of result is always axios AxiosResponse lt Resp gt data data I don t know if axios did it on purpose or ignored it In the GET request initiated above the type of the response data result is always axios AxiosResponse lt Resp gt but in fact we have already included response in the response interceptor data returned which caused the response data type to be confused How is it solved in alova As a more modern and more adaptable request solution for complex applications alova also provides a more elegant solution At the same time in order to reduce the learning cost the api design similar to axios is also maintained which looks very familiar alova is pronounced as Alova Although it starts with a like axios the following two names need to be distinguished Deep integration with UI framework automatically manage request related dataSuppose we need to initiate a basic data acquisition request take vue as an example and compare the code directly axios lt template gt lt div v if loading gt Loading lt div gt lt div v else if error class error gt error message lt div gt lt div v else gt data lt div gt lt template gt lt script setup gt import axios from axios import ref onMounted from vue const loading ref false const error ref null const data ref null const requestData gt loading value true axios get http xxx index then result gt data value result catch e gt error value e finally gt loading value false onMounted requestData lt script gt alova lt template gt lt div v if loading gt Loading lt div gt lt div v else if error class error gt error message lt div gt lt div v else gt data lt div gt lt template gt lt script setup gt import createAlova useRequest from alova const pageData createAlova baseURL http xxx Get index const loading data error useRequest pageData lt script gt In axios you need to create the corresponding request status and maintain it yourself but alova takes over this work for you High performance features out of the boxTraditional Promise style request tools are mainly positioned to simplify requests through Promise and improving performance may be the least of their considerations However Alova which is a request policy library emphasizes this point In Alova memory is enabled by default Cache and request sharing these two can greatly improve request performance improve user experience and reduce server pressure let s take a look at them one by one memory cacheThe memory mode is to save the response data in the local memory after the request is responded When the same request is made next time the cached data will be used instead of sending the request again Imagine that when you are implementing a list page click on the list item You can enter the details page to view the data You would think that users may frequently click to view the details in the list When the details data has not changed it would be too wasteful to request once every time they enter the details page and each time they need the user Waiting to load In alova you can enjoy such treatment by default the effect is shown belowRequest to shareYou may have encountered this situation When a request is sent but has not been responded to the same request is initiated again resulting in waste of requests or repeated submission of problems such as the following three scenarios A component will obtain initialization data when it is created When a page renders multiple components at the same time it will send multiple identical requests at the same time The submit button is not disabled and the user clicks the submit button multiple times When the preloading page is entered before the preloading is completed the same request will be initiated multiple times Sharing requests are used to solve these problems It is realized by multiplexing requests Since this kind of case cannot be displayed intuitively it will not be displayed Interested partners can experience it by themselves In addition alova which claims to be a request strategy library also provides request strategies in specific scenarios which we will introduce below Interested partners please continue to read Lightweight sizeAlova in the compressed state is only kb only of axios see the screenshot belowLink here More intuitive response data TS typeIn axios it is really confusing that you want to define the type of response data If you are a heavy user of Typescript alova can provide you with a complete type experience When you define the type of response data at the request You can enjoy it in multiple places it will make you feel very clear let s take a look interface Resp id number const pageData createAlova baseURL http xxx Get lt Resp gt index const data data type is Resp loading error onSuccess send useRequest pageData onSuccess event gt When getting the response data in the success callback the value type of event data is also Resp console log event data const handleClick async gt The send function can manually send the request again it will receive the response data and its value type is still Resp const data await send So far compared to the traditional Promise style request library you may have a preliminary understanding of the power of alova But it has so much more than that other features of alova Support multiple UI frameworks at the same timeAlova supports react vue and svelte at the same time no matter which UI framework you use it can satisfy you API design similar to axios easier to use and familiarAlova s request information structure is almost the same as that of axios Let s compare their GET and POST requests GET request axiosaxios get index set request header headers Content Type application json charset UTF params parameter params userId alovaconst todoListGetter alovaInstance Get index set request header headers Content Type application json charset UTF params parameter params userId POST request axiosaxios post login username xxx password ppp set request header headers Content Type application json charset UTF params parameter params userId alovaconst loginPoster alovaInstance Post login username xxx password ppp set request header headers Content Type application json charset UTF params parameter params userId request strategy high performance paging request strategyAutomatically maintain paging related data and status and provide common paging data operation capabilities According to the official introduction it can improve the fluency of the list page by and reduce the difficulty of coding by The following is an example provided by the official Interested students can go and see Example of paginated listExample of pull down loading request strategy non inductive data interactionIn my opinion this non inductive data interaction request strategy can be described as a great initiative I understand it as a more reliable optimistic update The official website explains it like this Non inductive data interaction means that when users interact with the application relevant content can be displayed immediately without waiting or the operation result can be displayed without waiting when submitting information just like interacting with local data which greatly improves the application experience Fluency it allows users not to perceive the lag caused by data transmission It can minimize the problems caused by network fluctuations and your application is still available on high latency networks or even disconnected networks During my experience even in the weak network state I can feel a smooth feeling without delay so please come and experience it As far as I understand it uses the following techniques A persistent request queue to ensure the security and serialization of requests Request a retry policy mechanism to ensure the smooth completion of the request Dummy response data an innovative concept to serve as a placeholder for unresponsive data so that it can be positioned and replaced with actual data after a response More specific information about sensorless data interaction can be found on the official website Data pre fetchingThe data is preloaded by pulling the data and cached locally When this part of the data is actually used it can hit the cache and display the data directly This method also greatly improves the user experience write at the endIn short as a request tool for the new generation alova has great potential If you want to try it you can click the link below to learn more alova official websitealova s Github addressWriting is not easy I have seen this why don t you order a free heart for me Thank you for your likes |
2023-06-14 04:04:27 |
海外TECH |
CodeProject Latest Articles |
Unveiling the Counterintuitive Nature of the Monty Hall Problem - A Simulation-Based Investigation |
https://www.codeproject.com/Tips/5362654/Unveiling-the-Counterintuitive-Nature-of-the-Monty
|
Unveiling the Counterintuitive Nature of the Monty Hall Problem A Simulation Based InvestigationThis post delves into the perplexing Monty Hall paradox examining the probabilities associated with sticking or switching doors in the game scenario |
2023-06-14 04:18:00 |
金融 |
ニッセイ基礎研究所 |
欧州経済見通し-インフレ率低下で、今後は緩やかな回復へ |
https://www.nli-research.co.jp/topics_detail1/id=75092?site=nli
|
目次経済・金融環境の現状・振り返りエネルギー主導でのインフレ圧力は和らぐ・ガス備蓄今年の貯蔵も順調・実体経済小幅だが四半期連続のマイナス成長・物価・賃金賃金上昇率が記録的な水準に上昇・財政政策物価高対策も縮小へ・金融政策・金利利上げサイクルの終わりは近い経済・金融環境の見通し・見通し成長率は緩やかに回復へ・リスク高インフレ長期化リスクが当面の懸念振り返りエネルギー主導でのインフレ圧力は和らぐ欧州経済は、コロナ禍で大きく落ち込んだ後、回復基調を辿っていたが、ロシアがウクライナに侵攻して以降はエネルギー価格が高騰し、景気の停滞感が強まっていた。 |
2023-06-14 13:41:31 |
海外ニュース |
Japan Times latest articles |
Two dead after shooting at Self-Defense Forces gun range in central Japan |
https://www.japantimes.co.jp/news/2023/06/14/national/sdf-range-shooting-incident/
|
Two dead after shooting at Self Defense Forces gun range in central JapanAn year old male suspect a member of the Self Defense Forces was arrested at the scene for attempted murder according to NHK |
2023-06-14 13:02:05 |
ニュース |
BBC News - Home |
Nottingham: Students among three killed in knife and van attacks |
https://www.bbc.co.uk/news/uk-england-nottinghamshire-65893694?at_medium=RSS&at_campaign=KARANGA
|
attackstwo |
2023-06-14 04:44:34 |
ニュース |
BBC News - Home |
Nottingham attacks: What we know so far |
https://www.bbc.co.uk/news/uk-65890403?at_medium=RSS&at_campaign=KARANGA
|
nottingham |
2023-06-14 04:45:56 |
マーケティング |
MarkeZine |
電通ら、グループ横断EC専門チーム「dentsu EC growth」発足 事業ステージに合わせ支援 |
http://markezine.jp/article/detail/42503
|
dentsuecgrowth |
2023-06-14 13:30:00 |
IT |
週刊アスキー |
OpenAI、LLMを大幅アップデート 関数呼び出しで外部ツールと連携が可能に |
https://weekly.ascii.jp/elem/000/004/140/4140838/
|
gptturbo |
2023-06-14 13:50:00 |
IT |
週刊アスキー |
一足早く見られる! 「劇場版シティーハンター 天使の涙」TOHOシネマズ新宿で舞台挨拶付きの試写会開催へ |
https://weekly.ascii.jp/elem/000/004/140/4140863/
|
実施予定 |
2023-06-14 13:40:00 |
IT |
週刊アスキー |
ここでしか観られないドラえもんが盛り沢山! ハウステンボス「THE ドラえもん展 NAGASAKI 2023」開催 |
https://weekly.ascii.jp/elem/000/004/140/4140882/
|
nagasaki |
2023-06-14 13:30:00 |
IT |
週刊アスキー |
見つけて楽しい、食べて美味しいワシントンホテル×八景島シーパラダイス コラボランチ |
https://weekly.ascii.jp/elem/000/004/140/4140862/
|
bayside |
2023-06-14 13:10:00 |
コメント
コメントを投稿