Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am running into an issue where the first if statement is true and returns the "No plug available. I am not sure what props.plugs.length means and/or where to look to fix this.

window.PlugsView = function (props) {
	if (props.plugs.length == 0)
		return (<div>No plug available.</div>);

	var rows = props.plugs.map(function (plug) {
		return (
			<PlugCard key={plug.name}
				plug={plug} />);
	});

	return (
		<div>
			{rows}
		</div>);
}


What I have tried:

Have not tried much, not sure where to start.
Posted
Updated 2-May-22 19:23pm
Comments
Richard MacCutchan 2-May-22 15:46pm    
It is the number of plugs in props. But you have not explained what either of those variable names refer to.
Sandeep Mewara 3-May-22 0:40am    
Believe you are talking of react. If so, would help you if you share more details and complete code.

1 solution

props is the parameter to the function, plugs is a property of the class that props is an instance of, and length is how long it is. Presumably, plugs is a collection of some class instances, and that means that props.plugs.length returns the number of items in the collection.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900