**Client's Browser**
|
| DNS
|
v
**Website Server**
|
// pages/index.js
import Link from 'next/link'
export default function HomePage() {
return (
<div>
<h1>Welcome to our news site!</h1>
<ul>
Do you know that if you call setIndexes([...indexes, index]);
too fast.. one after another time.. its possible only to update the array, but not to increment it?
The problem you're facing may be due to the asynchronous nature of the setState
function in React. When using the useState
hook, the setState
function doesn't update the state immediately, but during the next render of the component.
Your logic for adding values to the setIndexes
array can looks correct but.. However, when you use setIndexes([...indexes, index])
, you're actually accessing the previous value of uploadedFiles
, which may not be updated yet.
To solve this issue, you can use the functional form of setState
, where you take the previous value of the indexes
array and add the new value to it. Here's an example:
setIndexes((prevIndexes) => [...prevIndexes, index]);
<?php | |
define("CHATGPT_API_KEY", "your-key-goes-here"); | |
$data = array( | |
"model" => "text-davinci-003", | |
"prompt" => "What is PHP and how it works?", // Your question or request | |
"temperature" => 0.5, | |
"max_tokens" => 500 | |
); |
/** | |
* Make new class instance for each element | |
*/ | |
class ClickOutSide { | |
constructor() { | |
this.outsideHandler = null | |
this.element = null | |
this.documentEvent = (evt) => { | |
const flyoutEl = this.element | |
let targetEl = evt.target // clicked same el |
Unit Tests are written from a programmers perspective. They are made to ensure that a particular method (or a unit) of a class performs a set of specific tasks.
Functional Tests are written from the user's perspective. They ensure that the system is functioning as users are expecting it to.
- Buffer is temporary placeholder in memory (ram/disk) on which data can be dumped and then processing can be done.
- Stream is a sequence of data elements. like when you typing something in your computer then when you press the keys it will form a data stream and then it goes to the processor for processing.
Stream can be processed through Buffer.
A buffer is a temporary memory that a stream takes to hold some data until it is consumed.
RUN - command triggers while we build the docker image.
CMD - command triggers while we launch the created docker image.
RUN EXPLAIN: RUN is an image build step, the state of the container after a RUN command will be committed to the container image. A Dockerfile can have many RUN steps that layer on top of one another to build the image. RUN: Commands May not Execute if Images are Cached.
Did you know that instagram webview (when click some link from private message or post) , the window.opener is null? | |
This is privacy reason.. so if you wants to close window popups, should use history.back(); instead of window.close();, | |
also the postMessage will not works with window.opener.postMessage .... |