84 questions with no answers
5
votes
0
answers
678
views
Lint shows error when I use spread syntax and destructuring
I have problem with spread and destructuring operator.
After npm run lint:js I'll see:
TypeError: Cannot read property 'type' of undefined
Occurred while linting C:\Users\USER\hq-manager-frontend\...
1
vote
0
answers
31
views
Invalid attempt to destructuring non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method
I am building a react native application to display nearby hospitals. The error is at AppMapView & ListView component
const [placeList, setPlaceList] = useState([]);
ere, placeList is not empty. ...
2
votes
0
answers
50
views
Why can't internal destructuring be done using rest when object destructuring in JavaScript?
I cannot use it like this.
const { a, ...{ b } } = { a: 1, b: 2 };
I wonder what's the reason? I found this on mdn but I didn't fully understand it.
"On the other hand, object destructuring can ...
0
votes
0
answers
247
views
Can I destructure an instance of a class in Dart? Not an array of primitives, but an object:
For example, an instance of the following class:
class ScanModel {
ScanModel({
this.id,
this.tipo,
required this.valor,
});
int? id;
String? tipo;
String ...
0
votes
0
answers
690
views
extract data key and pass it to store vue pinia
I'm trying to sent data to store action. How can I extract data keys firstName, lastName and pass it to store ? Now I'm getting an error "Property 'firstName', 'firstName' does not exist on type '...
1
vote
0
answers
70
views
Is it possible to use a destructuring assignment for an array of objects?
Say I have the following:
const db = {players: [{elo:3}, {elo:4}]}
I can do this
const [white, black] = db.players
But what if I want to get the elo fields? I can do this:
const [{elo:elo1}, {elo:...
0
votes
0
answers
45
views
Why am I getting undefined on console when I am passing props in my component file?
I tried logging it onto console and I was getting undefined wherever I have used props,hence nothing is coming onto my browser wherever I have used props.The tags after it are working totally fine as ...
1
vote
0
answers
285
views
Destructuring object in a event handler parameter
const handleChange = ({ target }) => {
const name = target.name;
const value = target.value;
setProfile({
[name]: value
});
};
<input value={phone} onChange={...
1
vote
0
answers
38
views
How to set default dependent props when using destructuring assignment?
Destructuring assignment is a well known method for assigning default props to React components:
interface ButtonProps {
onClick: () => void;
disabled?: boolean;
getTextColor?: (theme: Theme) ...
2
votes
0
answers
3k
views
Destructuring assignment with JSON parsed string
I want to assign with the destructuring method a variable with a localStorage item.
This seems to work.
const { item } = localStorage
But my item is a stringified object and i want it as an object.
...
2
votes
0
answers
435
views
Spread operator in destructured v-for (Vue.js 2 with 'vue-template-babel-compiler')
I would like to use a spread operator in a destructured v-for loop in Vue.js 2 working with vue-template-babel-compiler. I need the latter in the first place to compile the optional chaining operator ...
0
votes
0
answers
317
views
Can I combine spread and rest in destructuring object in Javascript?
Let us have this object:
// Values of properties are irelevant
let row = {_x: "x", _y: "y", _z: "z", a: "a", b: "b"}
I need to get copy of this ...
0
votes
0
answers
43
views
How can I pass destructured elements one by one to scrollDown() function?
I want to pass aboutSection,servicesSection to scrollDown() method one by one so that when I click on About and Services in Navbar scrollDown() method runs and provide the desired functionality. But I ...
1
vote
0
answers
130
views
How to deconstruct a parameter that contains a special character?
I am using querysString.parse to deconstruct the URL parameters, and some of them have brackets [].
This is part of the string that I am deconstructing title=wasabi&calories=50&nutrients%5BCA%...
2
votes
0
answers
244
views
Assigning default value during destructuring in v-slot
The project set up by vue-cli and the options are babel, router, vuex and eslint/prettier.
I was following vue official guide to use destructuring and assigning default value as described here.
<...