Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I'm getting the following error while trying to create a multimap with 'date' as the key and then iterate through the multimap which has arrays as it's values.
Type '{children: never[]; key: string; Index: string; Item: SomeItem[]; }' is not assignable to type 'IntrinsicAttributes & Props'. Property 'children' does not exist on type 'IntrinsicAttributes & Props'. ts(2322)
and not sure how to fix this
const History = () => {
const [counter, setCounter] = useState(0);
type SomeMap = Map<string, SomeItem[]>;
let map: SomeMap = new Map();
//Items is of type SomeItem[]
Items.foreach((item) =>{
if(map.has(item.date)){
(map.get(item.date) ?? []).push(item);
else{
map.set(item.date,[item]);
return(
<Accordian>
{ map.foreach((value, index) => {
setCounter(counter +1 );
key={index}
Index={counter.toString()}
Item={value}>
</Task>
</Accordian>
type Props = {
index: string;
Item: SomeItem[];
const Task = (props:Props) => {
const index = props.Index;
const Item = props.SomeItem;
render(/*Some Code*/);
Task
is not typed to receive
children
, but you are actually passing a newline text node as the task's children.
key={index}
Index={counter.toString()}
Item={value}>{/* there is a new line text node here */}
</Task>
You probably want to make the JSX tag self closing to ensure it has no children:
key={index}
Index={counter.toString()}
Item={value}
Playground
In my case, Im using Styled Components and Primereact libraries.
The issue throw me when I create Style componet inheriting to a Primereact component (TabView), to solve this problem I add children as Styled Component Prop:
import { TabView } from 'primereact/tabview';
import styled from 'styled-components';
type ChildrenProp = {
children: React.ReactNode;
export const ChatTabView = styled(TabView)<ChildrenProp>`
// css code
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.