LaRynk
LaRynk
RReactiflux
Created by LaRynk on 4/4/2023 in #help-js
✅ – Rinkusu – 14-53 Apr 4
nvm I made a php script, thx anyway
5 replies
RReactiflux
Created by LaRynk on 3/25/2023 in #help-js
Rinkusu – 13-39 Mar 25
Or how do I get the pixels array from an image FILE with canvas methods
2 replies
RReactiflux
Created by LaRynk on 10/31/2022 in #help-js
Axel (Rinkusu) – 15-49 Oct 31
it is, so what can I do please ?
4 replies
RReactiflux
Created by LaRynk on 10/31/2022 in #help-js
✅ – Axel (Rinkusu) – 08-39 Oct 31
it was just a number, a position, because I'm looking for a "newPosition", and you see "newPosition"s. anyway I found a solution with reduce
7 replies
RReactiflux
Created by LaRynk on 10/31/2022 in #help-js
✅ – Axel (Rinkusu) – 08-39 Oct 31
I want a one-liner check of "newPosition" for the value of "SELECTED_POS"
7 replies
RReactiflux
Created by LaRynk on 10/30/2022 in #help-js
✅ – Axel (Rinkusu) – 20-53 Oct 30
thx anyway !
18 replies
RReactiflux
Created by LaRynk on 10/30/2022 in #help-js
✅ – Axel (Rinkusu) – 20-53 Oct 30
it works like this:
if (nextColor === brownColor) {
newElem.piece = {
color: i < 24 ? 'black' : i > 39 ? 'white' : undefined,
isLady: false
}
}
if (nextColor === brownColor) {
newElem.piece = {
color: i < 24 ? 'black' : i > 39 ? 'white' : undefined,
isLady: false
}
}
18 replies
RReactiflux
Created by LaRynk on 10/30/2022 in #help-js
✅ – Axel (Rinkusu) – 20-53 Oct 30
no it would be an invalid left-assignement expression I guess
18 replies
RReactiflux
Created by LaRynk on 10/30/2022 in #help-js
✅ – Axel (Rinkusu) – 20-53 Oct 30
Because first, "piece" is undefined. So how can I set it to an object with a color attribute inside of it please ?$
18 replies
RReactiflux
Created by LaRynk on 10/30/2022 in #help-js
✅ – Axel (Rinkusu) – 20-53 Oct 30
Ok, I reworked and got this:
let newTiles = Array(64).fill({color: undefined, piece: undefined})
let nextColor = beigeColor

setTiles(newTiles?.map((elem, i) => {
let newElem = {...elem}

if (i % 8 !== 0) {nextColor = nextColor === beigeColor ? brownColor : beigeColor}
if (nextColor === brownColor) {
newElem.piece.color = i < 24 ? 'black' : i > 39 ? 'white' : undefined
}
newElem.color = nextColor
return newElem
}))
}
let newTiles = Array(64).fill({color: undefined, piece: undefined})
let nextColor = beigeColor

setTiles(newTiles?.map((elem, i) => {
let newElem = {...elem}

if (i % 8 !== 0) {nextColor = nextColor === beigeColor ? brownColor : beigeColor}
if (nextColor === brownColor) {
newElem.piece.color = i < 24 ? 'black' : i > 39 ? 'white' : undefined
}
newElem.color = nextColor
return newElem
}))
}
"Cannot set properties of undefined (setting 'color')"
18 replies
RReactiflux
Created by LaRynk on 10/30/2022 in #help-js
✅ – Axel (Rinkusu) – 20-53 Oct 30
18 replies
RReactiflux
Created by LaRynk on 10/30/2022 in #help-js
✅ – Axel (Rinkusu) – 20-53 Oct 30
how is it possible ? xD
18 replies
RReactiflux
Created by LaRynk on 10/30/2022 in #help-js
✅ – Axel (Rinkusu) – 20-53 Oct 30
18 replies