IT |
気になる、記になる… |
画面内蔵型Face IDの採用は2024年発売の「iPhone 16」からか − 2人の著名アナリストが同様の予想 |
https://taisy0.com/2022/04/02/155401.html
|
apple |
2022-04-02 13:52:46 |
AWS |
lambdaタグが付けられた新着投稿 - Qiita |
LambdaからDynamoDBを操作する |
https://qiita.com/zumastee/items/93f9301e7c8cea8883c0
|
LambdaからDynamoDBを操作する背景・目的以前、「VPC内のLambdaからインターネットに接続する」と「DynamoDBを試してみた」で作成したLambdaとDynamoDB以降、DDBという。 |
2022-04-02 22:03:49 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
俺は長文matplotlibをやめるぞ!ジョジョーーーッ!! |
https://qiita.com/mochi_gu_ma/items/aea51bb986092783f073
|
辞書の代わりにdataclassを使うことで、図の設定を少し流用しやすくするという意図です。 |
2022-04-02 22:38:51 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
Pythonの判定(排他的論理和) |
https://qiita.com/zuotianzhiye/items/4e1ce584529763914005
|
Pythonの判定排他的論理和pythonでの排他的論理和の判定例えば、入力チェックをする際に、両方値が入っているもしくは、入っていない場合は不可で、どちらか一方のみ値が入力されている状態を正とする場合のチェック処理xorpy入力データ判定対象のデータdatadatadatatestboolでキャストしなくてもよいが明示的にしてみたifbooldatadatabooldatadataprint排他的上記のようにを使えば排他的論理和の確認ができる。 |
2022-04-02 22:32:12 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
コメントやコミットメッセージについてまとめる |
https://qiita.com/dosukoi_man/items/324328f2b8f9e53de93e
|
参考Gitのコミットメッセージの書き方Prefix意味update機能修正バグではないadd新規ファイル機能追加remove削除ファイルmergeマージコミットemojiprefix絵文字をコミットメッセージのプレフィックスに使うこともできます。 |
2022-04-02 22:39:40 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
高速 scatter plot 描画(apache-arrow + regl 利用) |
https://qiita.com/kkdd/items/90c19cb6891817952143
|
reglWebGLを利用し高速描画処理を行なっています。 |
2022-04-02 22:20:37 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
Amazon Direct Connectの基本情報 |
https://qiita.com/liverpool_toki/items/1475686d2d366ca9d67a
|
また基本的に受け口の変更は後からできないため、専有型であれば、ダウンタイムが発生してしまいますが、一度削除したあと、再作成が自分でできたりしますが、共有型であれば、自分で設定ができないため、諦めるかDirectConnectを提供していただいている業者にお願いするかになります。 |
2022-04-02 22:16:28 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
LambdaからDynamoDBを操作する |
https://qiita.com/zumastee/items/93f9301e7c8cea8883c0
|
LambdaからDynamoDBを操作する背景・目的以前、「VPC内のLambdaからインターネットに接続する」と「DynamoDBを試してみた」で作成したLambdaとDynamoDB以降、DDBという。 |
2022-04-02 22:03:49 |
技術ブログ |
Developers.IO |
cve-2022-22965 Spring4Shell の影響調査 |
https://dev.classmethod.jp/articles/springboot-spring4shell/
|
cvespringshell |
2022-04-02 13:55:08 |
海外TECH |
MakeUseOf |
How to Find and Follow Friends on Apple Music |
https://www.makeuseof.com/how-to-find-follow-friends-on-apple-music/
|
people |
2022-04-02 13:45:14 |
海外TECH |
MakeUseOf |
Wi-Fi Extender vs. Mesh Router: Which Gives You the Best Network Coverage? |
https://www.makeuseof.com/wifi-extender-vs-mesh-router-which-is-best/
|
Wi Fi Extender vs Mesh Router Which Gives You the Best Network Coverage Mesh routers and Wi Fi extenders are two popular options to boost your Wi Fi coverage But which one comes out on top Let s find out |
2022-04-02 13:45:13 |
海外TECH |
MakeUseOf |
How to Set a Custom Accent Color for Material You in Android 12 |
https://www.makeuseof.com/set-custom-accent-color-android-12/
|
How to Set a Custom Accent Color for Material You in Android The wallpaper based theming system in Android is great but it has limitations Here s how to bypass them and choose your own custom accent colors |
2022-04-02 13:30:13 |
海外TECH |
MakeUseOf |
Slack for Gmail: What Is It & How Do You Use It? |
https://www.makeuseof.com/slack-for-gmail-how-to-use/
|
gmail |
2022-04-02 13:15:13 |
海外TECH |
MakeUseOf |
Ugoos UT8 PRO TV Box is Proof That Android TV Needs a Better User Interface |
https://www.makeuseof.com/ugoos-ut8-pro-review-android-tv-box/
|
Ugoos UT PRO TV Box is Proof That Android TV Needs a Better User InterfaceIf you re looking for an Android TV box the Ugoos UT PRO is a strong contender But is it worth the hassle compared with an Amazon Fire TV box |
2022-04-02 13:05:13 |
海外TECH |
DEV Community |
All React Hooks and Concepts In A Single Post!! 🤗 |
https://dev.to/nyctonio/all-react-hooks-and-concepts-in-a-single-post-1daf
|
All React Hooks and Concepts In A Single Post First of all React is a JS Library not a Complete Framework so for making a complete web application you need to know a lot of other things that you can use with React In this Post I will cover React concepts Hooks and some good practices Ofc We use React to make reusable components that can be used in a logical way to make UI Making components in React is as easy as making a function For Example it is a simple react component in which we can pass data as arguments which can be easily referenced inside the functionsfunction Component props return lt h gt props text lt h gt Ohk But Now what are States in React The state object is where you store property values that belongs to the component When the state object changes the component re renders which basically allows us to manage changing data in an application Now Lets Learn about states using useState useState const component gt Tip use states only inside components lets console log the state and lets see what it returns console log useState this will return an array f basically this returns a state and a function to update the state we can destructure the array and get the state and the function const state setState useState return lt div gt hiiieeee lt div gt but you can t ️directly update the value of state by using operator as this will change the value but it will not re render the component so basically react wants that you pass the value in the setState function if you need to change the state passing functions inside the useState you can also pass function in useState it will set the initial value to what function returns it is useful when you use computationaly high task as initial stateconst state setState useState gt console log initial state return passing functions inside the setState onClick gt here value in the props is the state setState value gt you can use this method when you need to update the state and you need the previous value of state return value useEffect Use effect hook has parts first one is a function and second one is dependency array which is optionaluseEffect gt we will get a console log every time any state changes for example if you have states in your component and any of them changes then we will get the console log this is something we mostly dont want useEffect gt console log change Your first useEffect call will always run when your component gets mounted first time in the DOM Dependency array We can specify the states inside the dependency array of useEffect so that it will only monitor the changes of those states which are mentioned in the dependency array const state setState useState const state setState useState useEffect gt console log state changed state Remember Do not update the state in which you used the useEffect without a proper logic it will create an infinite loop Cleanup functionuseEffect always returns a cleanup function which you can use to remove unwanted behaviours thec leanup function does not only run when our component wants to unmount it also runs right before the execution of the next scheduled effect read in detailuseEffect gt console log state changed state return gt console log state unmounted state state you can fetch data from an api like this useEffect gt const url const fetchData gt fetch url then res gt res json then data gt setState data title fetchData useContext The Context API provides data even to the deepest level of component in the react component tree without passing it in propsimport createContext from react import useState from react const StoreContext createContext const component gt const data useState name Ritesh email nyctonio dev gmail com const Child gt return lt div gt lt StoreContext Consumer gt value gt lt h gt name is value name lt h gt lt StoreContext Consumer gt lt div gt return lt StoreContext Provider value data gt lt Child gt lt StoreContext Provider gt export default component You can wrap your top level component in Your Context Provider and use it inside a function by Context Consumer What useContext do is it replaces Context Consumer and we can get data by using useContext directly See this example import createContext useContext from react import useState from react const StoreContext createContext const component gt const data useState name Ritesh email nyctonio dev gmail com const Child gt const value useContext StoreContext return lt div gt lt h gt name is value name lt h gt lt div gt return lt StoreContext Provider value data gt lt Child gt lt StoreContext Provider gt export default component read more useReducer useReducer is used for state management in React it is somewhat similar to reducer function in javascript useReducer function accepts params reducer function and initialStateuseReducer reducer initialState reducer functions accepts params currentState and action for that and returns a new Statereducer currentState action lets create a simple counter using useReducerimport useReducer from react const initialState const reducer state action gt switch action case increment return state case decrement return state default return state export default function main const count dispatch useReducer reducer initialState return lt div gt lt p gt Count count lt p gt lt button onClick gt dispatch increment gt lt button gt lt button onClick gt dispatch decrement gt lt button gt lt div gt we can make it more complex by making our state an objectimport useReducer from react const initialState firstCounter secondCounter const reducer state action gt switch action type case increment return state firstCounter state firstCounter action value case decrement return state firstCounter state firstCounter action value default return state export default function main const count dispatch useReducer reducer initialState return lt div gt lt p gt Count count firstCounter lt p gt lt button className bg gray p onClick gt dispatch type increment value gt increase by lt button gt lt button className bg gray p onClick gt dispatch type decrement value gt decrease by lt button gt lt div gt Or We can use multiple useReducers import useReducer from react const initialState const reducer state action gt switch action case increment return state case decrement return state default return state export default function main const count dispatch useReducer reducer initialState const count dispatch useReducer reducer initialState return lt div gt lt p gt Count count lt p gt lt button className bg gray p m onClick gt dispatch decrement gt lt button gt lt button className bg gray p m onClick gt dispatch increment gt lt button gt lt p gt Count count lt p gt lt button className bg gray p m onClick gt dispatch increment gt lt button gt lt button className bg gray p m onClick gt dispatch decrement gt lt button gt lt div gt When to use useState and when useReducer useReducer is usually preferable to useState when you have complex state logic that involves multiple sub values or when the next state depends on the previous one useReducer also lets you optimize performance for components that trigger deep updates because you can pass dispatch down instead of callbacks useReducer with useContext With the use of useContext and useReducer we can manage global states at any level of component tree try out this example main jsximport React from react import useReducer from react import ChildrenA from components ChildrenA export const StateContext React createContext const initialState const reducer state action gt switch action case increment return state case decrement return state default return state export default function main const count dispatch useReducer reducer initialState return lt div gt lt StateContext Provider value countState count countDispatch dispatch gt lt ChildrenA gt lt StateContext Provider gt lt div gt ChildrenA jsximport React from react import ChildrenB from ChildrenB import StateContext from pages main import useContext from react export default function ChildrenA const countState countDispatch useContext StateContext return lt div gt In child A count state is countState lt ChildrenB gt lt div gt ChildrenB jsximport React from react import StateContext from pages main import useContext from react export default function ChildrenB const countState countDispatch useContext StateContext return lt div gt lt p gt Count is countState lt p gt lt button onClick gt countDispatch increment gt lt button gt lt button onClick gt countDispatch decrement gt lt button gt lt div gt your both state will change simultaneously useCallback lets see this code and try to understand the behaviour of functions in Reactimport React from react export default function main function Sum return a b gt a b const func Sum const func Sum console log func func return lt div gt main lt div gt If you will run this code you will get false in console logNow with an example lets try to understand how we can use useCallback main jsximport React useState from react import ChildrenA from components ChildrenA import ChildrenB from components ChildrenB import ChildrenC from components ChildrenC const main gt const state setState useState const state setState useState const handleClickA gt setState state const handleClickB gt setState state return lt div className flex flex col justify center items center gt lt ChildrenA value state handleClick handleClickA gt lt ChildrenB value state handleClick handleClickB gt lt ChildrenC gt lt div gt what react memo do is it re render the component only when the props changeexport default React memo main ChildrenA jsximport React from react function ChildrenA value handleClick console log ChildrenA return lt div gt ChildrenA value lt button className bg gray p m onClick handleClick gt Click lt button gt lt div gt export default React memo ChildrenA ChildrenB jsximport React from react function ChildrenB value handleClick console log ChildrenB return lt div gt ChildrenB value lt button className bg gray p m onClick handleClick gt Click lt button gt lt div gt export default React memo ChildrenB ChildrenC jsximport React from react function ChildrenC console log ChildrenC return lt div gt ChildrenC lt div gt export default React memo ChildrenC when you see console log in your browser initially all three components renders but on clicking any click button only components rerenders Note here we used React memo thats why ChildrenC do not got rerendered because the props do not changed but why on changing ChildrenA ChildrenB also gets re render The reason is on rerender of main function the handleClick function do not remains the same as previous one I explained this above in the blog thats why React notices change in props so it rerenders both ChildrenA and ChildrenB To Solve this we will use useCallback useCallback returns a memoized callback useCallback accepts a function and a dependency array same as useEffectnow lets change our code in main function and see the logs main jsximport React useState useCallback from react import ChildrenA from components ChildrenA import ChildrenB from components ChildrenB import ChildrenC from components ChildrenC const main gt const state setState useState const state setState useState const handleClickA useCallback gt setState state state const handleClickB useCallback gt setState state state return lt div className flex flex col justify center items center gt lt ChildrenA value state handleClick handleClickA gt lt ChildrenB value state handleClick handleClickB gt lt ChildrenC gt lt div gt what react memo do is it re render the component only when the props changeexport default React memo main now you can see everything is fine useMemo useCallback returns a memorized function similarly useMemo returns a memorized value for example we need to find the factorial and only recalculate when number changes not everytime when component re renders so we will use useCallbackimport React useState useMemo from react function factorialOf n console log factorialOf n called return n lt n factorialOf n const main gt const number setNumber useState const factorial useMemo gt factorialOf number number const count setCount useState return lt div className flex flex col justify center items center gt factorial lt button className bg gray p m onClick gt setNumber number gt lt button gt count lt button className bg gray p m onClick gt setCount count gt lt button gt lt div gt export default main useRef lets console log useRef and see what it returnsconsole log useRef this will return something like this current useRef returns a mutable ref object whose current property is initialized to the passed argument initialValue The returned object will persist for the full lifetime of the component when you compare an normal object with itself in useEffect after a rerender those are not the same and that will trigger the useEffect on that object you can run this code and try out import useEffect useState useRef from react const component gt const obj hi const obj useRef hi console log obj obj current const state setState useState gt return useEffect gt console log obj changed obj obj useEffect gt console log obj changed obj current obj return lt div onClick gt setState value gt return value className w screen h screen flex justify center items center text xl font extralight gt state lt div gt export default component you can also use useState to work similar to useRefconst obj useState current hurrayyyyy you have covered all important hooks Connect me on Twitter Twitter Do check out my Github for amazing projects Github Connect me on LinkedIn Linkedin Read my another article Authentication in nodejs with mongodb bcrypt and jwt web tokens |
2022-04-02 13:09:34 |
Apple |
AppleInsider - Frontpage News |
Apple TV+'s 'Prehistoric Planet' set for week-long series premiere from May 23 |
https://appleinsider.com/articles/22/04/02/apple-tvs-prehistoric-planet-set-for-week-long-series-premiere-from-may-23?utm_medium=rss
|
Apple TV x s x Prehistoric Planet x set for week long series premiere from May Apple has teased its upcoming release of Prehistoric Planet a five episode series about dinosaurs that will premiere on Apple TV over the course of a week Starting from May until May Apple TV will premiere a new episode of Prehistoric Planet to subscribers each day To tease the week long event the Apple TV YouTube channel has been updated with a brief video showing what to expect from the series Executive produced by John Favreau and Mike Gunton and working with the BBC Studios Natural History Unit that previously released Planet Earth Prehistoric Planet will offer a view of what Earth and its inhabitants looked like million years ago Read more |
2022-04-02 13:52:34 |
海外科学 |
NYT > Science |
Cuts in Britain Could Cause a Covid Data Drought |
https://www.nytimes.com/2022/04/02/science/covid-testing-uk-denmark.html
|
experts |
2022-04-02 13:28:35 |
海外科学 |
NYT > Science |
What to Know About the Bird Flu Outbreak |
https://www.nytimes.com/article/bird-flu.html
|
backyard |
2022-04-02 13:05:57 |
ニュース |
BBC News - Home |
Dover queues due to shortage of cross-Channel ferries |
https://www.bbc.co.uk/news/uk-england-kent-60965245?at_medium=RSS&at_campaign=KARANGA
|
dover |
2022-04-02 13:24:51 |
ニュース |
BBC News - Home |
Liverpool 2-0 Watford: Diogo Jota & Fabinho secure 10th straight Premier League win |
https://www.bbc.co.uk/sport/football/60883947?at_medium=RSS&at_campaign=KARANGA
|
Liverpool Watford Diogo Jota amp Fabinho secure th straight Premier League winLiverpool beat struggling Watford to complete a remarkable return to the top of the Premier League for a few hours at least |
2022-04-02 13:46:54 |
ニュース |
BBC News - Home |
Daniil Medvedev faces race to be fit for French Open after hernia surgery |
https://www.bbc.co.uk/sport/tennis/60966957?at_medium=RSS&at_campaign=KARANGA
|
Daniil Medvedev faces race to be fit for French Open after hernia surgeryRussian world number two Daniil Medvedev will have a procedure on a hernia putting a question mark over his participation in the French Open |
2022-04-02 13:46:41 |
北海道 |
北海道新聞 |
台湾列車事故1年、見えぬ改革 49人犠牲、運行トラブル減らず |
https://www.hokkaido-np.co.jp/article/664763/
|
列車事故 |
2022-04-02 22:16:57 |
北海道 |
北海道新聞 |
食品残渣を子牛の飼料に 札幌のエア・ウォーター物流 |
https://www.hokkaido-np.co.jp/article/664765/
|
飼料 |
2022-04-02 22:22:00 |
北海道 |
北海道新聞 |
国学院大、青学大など先勝 東都大学野球リーグ開幕 |
https://www.hokkaido-np.co.jp/article/664764/
|
別大興産スタジアム |
2022-04-02 22:18:00 |
仮想通貨 |
BITPRESS(ビットプレス) |
サクラエクスチェンジビットコイン、当社株主の変更・第三者割当増資および新経営体制に関するお知らせ |
https://bitpress.jp/count2/3_11_13147
|
第三者割当増資 |
2022-04-02 22:02:59 |
コメント
コメントを投稿