<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Seriti Aymen</title>
    <description>The latest articles on DEV Community by Seriti Aymen (@seritiaymen).</description>
    <link>https://dev.to/seritiaymen</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F820498%2Ff23e5a26-6bf4-48a2-89c8-a6bb64646d14.png</url>
      <title>DEV Community: Seriti Aymen</title>
      <link>https://dev.to/seritiaymen</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/seritiaymen"/>
    <language>en</language>
    <item>
      <title>TypeError: Cannot read properties of undefined (reading 'title')
</title>
      <dc:creator>Seriti Aymen</dc:creator>
      <pubDate>Wed, 23 Feb 2022 10:20:58 +0000</pubDate>
      <link>https://dev.to/seritiaymen/typeerror-cannot-read-properties-of-undefined-reading-title-42fn</link>
      <guid>https://dev.to/seritiaymen/typeerror-cannot-read-properties-of-undefined-reading-title-42fn</guid>
      <description>&lt;p&gt;I want to add the element selected of a select into a table and after inserting more than one element I get the error in the title!&lt;/p&gt;

&lt;p&gt;The elements of the select&lt;/p&gt;

&lt;p&gt;&lt;code&gt;export const getBP = () =&amp;gt; [&lt;br&gt;
  { id: "1", title: "A" },&lt;br&gt;
  { id: "2", title: "B" },&lt;br&gt;
  { id: "3", title: "C" },&lt;br&gt;
  { id: "4", title: "D" },&lt;br&gt;
  { id: "5", title: "E" },&lt;br&gt;
  { id: "6", title: "F" },&lt;br&gt;
  { id: "7", title: "G" },&lt;br&gt;
  { id: "8", title: "H" },&lt;br&gt;
  { id: "9", title: "I" },&lt;br&gt;
];&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;the function that I am using to get the elements from the local storage(since I am inserting them in local and then get them from there to the table&lt;/p&gt;

&lt;p&gt;&lt;code&gt;export function getAllDocument() {&lt;br&gt;
  if (localStorage.getItem(KEYS.documents) === null)&lt;br&gt;
    localStorage.setItem(KEYS.documents, JSON.stringify([]));&lt;br&gt;
  let documents = JSON.parse(localStorage.getItem(KEYS.documents));&lt;br&gt;
  let BPs = getBP();&lt;br&gt;
  return documents.map((x) =&amp;gt; ({&lt;br&gt;
    ...x,&lt;br&gt;
    emploi: BPs[x.Emploi - 1].title,&lt;br&gt;
  }));&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The Table element: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;TblContainer&amp;gt;&lt;br&gt;
          &amp;lt;TableBody&amp;gt;&lt;br&gt;
            {&lt;br&gt;
              records.map(item=&amp;gt;&lt;br&gt;
                (&amp;lt;TableRow key={item.id}&amp;gt;&lt;br&gt;
                  &amp;lt;TableCell&amp;gt;{item.Radical}&amp;lt;/TableCell&amp;gt;&lt;br&gt;
                  &amp;lt;TableCell&amp;gt;{item.emploi}&amp;lt;/TableCell&amp;gt;&lt;br&gt;
                  &amp;lt;TableCell&amp;gt;{item.Montant}&amp;lt;/TableCell&amp;gt;&lt;br&gt;
                  &amp;lt;TableCell&amp;gt;{item.Taux}&amp;lt;/TableCell&amp;gt;&lt;br&gt;
                  &amp;lt;TableCell&amp;gt;{item.Duree} mois&amp;lt;/TableCell&amp;gt;&lt;br&gt;
                  &amp;lt;TableCell&amp;gt;{item.DateE}&amp;lt;/TableCell&amp;gt;&lt;br&gt;
                  &amp;lt;TableCell&amp;gt;{item.DateP}&amp;lt;/TableCell&amp;gt;&lt;br&gt;
                &amp;lt;/TableRow&amp;gt;)&lt;br&gt;
              )&lt;br&gt;
            }&lt;br&gt;
          &amp;lt;/TableBody&amp;gt;&lt;br&gt;
        &amp;lt;/TblContainer&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This last element is the select component:&lt;/p&gt;

&lt;p&gt;`import React from 'react'&lt;br&gt;
import { FormControl, InputLabel, Select as MuiSelect, MenuItem, FormHelperText } from '@material-ui/core';&lt;/p&gt;

&lt;p&gt;export default function Select(props) {&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const { name, label, value,error=null, onChange, options } = props;

return (
    &amp;lt;FormControl variant="outlined"
    {...(error &amp;amp;&amp;amp; {error:true})}&amp;gt;
        &amp;lt;InputLabel&amp;gt;{label}&amp;lt;/InputLabel&amp;gt;
        &amp;lt;MuiSelect
            label={label}
            name={name}
            value={value}
            onChange={onChange}&amp;gt;
            &amp;lt;MenuItem value=""&amp;gt;None&amp;lt;/MenuItem&amp;gt;
            {
                options.map(
                    item =&amp;gt; (&amp;lt;MenuItem key={item.id} value={item.id}&amp;gt;{item.title}&amp;lt;/MenuItem&amp;gt;)
                )
            }
        &amp;lt;/MuiSelect&amp;gt;
        {error &amp;amp;&amp;amp; &amp;lt;FormHelperText&amp;gt;{error}&amp;lt;/FormHelperText&amp;gt;}
    &amp;lt;/FormControl&amp;gt;
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
`&lt;/p&gt;

</description>
      <category>react</category>
      <category>materialui</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
