Reputation: 1548
I have declared a map in my Main file. I have another file Test,to which i want to pass my map.Below is my Main.tsx file
const [testMap] = useState(new Map<string,PersonInfo|undefined>());
<Test list={testMap}/> //This is my Main.tsx file
Below is code for my Test.tsx file
interface Temp {
list:Map<string,PersonInfo|undefined>;
}
export default (
{list}:Temp
) => {
return (
<>
<p>
//Here i want to display the size of my map
</p>
</>
);
};
I want to display the size of the map that i have passed as parameter,but i am unable to do so.How can i fix this?
Upvotes: 0
Views: 553
Reputation: 172
You should be able to use
interface Temp {
list:Map<string,PersonInfo|undefined>;
}
export default ({list}:Temp) => {
return (
<p>
//Here i want to display the size of my map
{list.size()}
</p>
);
};
Also, if you want to use fragments, which is not necessary here, you have to make sure that the parent who calls your Test.jsx component displays it in a html element like a div.
<div>
<Test list={testMap}/> //This is my Main.tsx file
</div>
Upvotes: 1