https://matthewdaly.co.uk/blog/2022/12/11/what-i-think-chatgpt-means-for-developers/Published by at 11th December 2022 7:20 pm Naturally I decided to have a tinker with it as I was curious about it, and I've found it very useful for coding.

Here is an example of how you might do this: 1import React, { useState, useEffect } from 'react'; 2 3function useToast() { 4 const [toasts, setToasts] = useState([]); 5 6 function showToast(msg, type) { 7 setToasts(prevToasts => [...prevToasts, { msg, type }]); 8 }

35 ); 36 return () => timeoutIds.forEach(clearTimeout); 37 }, [toasts]); 38 39 return { 40 toasts, 41 showToast: (msg: string, type: string) => 42 dispatch({ type: 'SHOW_TOAST', payload: { msg, type }}), 43 hideToast: (index: number) => 44 dispatch({ type: 'HIDE_TOAST', payload: index }) 45 }; 46} 48function App() { 49 const { toasts, showToast, hideToast } = useToast(); 50 51 return ( 53 {toasts.map((toast, index) => (
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners