CodeWithHarry / iNotebook-React

INotebook is a React Application for managing personal notes on the cloud
343 stars 193 forks source link

'children' is missing in props validation #42

Closed nirmalsinghoo7 closed 1 year ago

nirmalsinghoo7 commented 1 year ago

In the NoteState.js file, I have added this code -

`import NoteContext from "./noteContext"; import React, {useState} from 'react';

const NoteState = (props) => { const notesInitial = [ { "_id": "63aea9ac4dba234bd0ea172b", "user": "63adb3ea747342cfad673030", "title": "My First Updatedfdsf", "description": "Updated This is the descrsdfiption ofsdfsd my first title", "tag": "Personal", "date": "2022-12-30T09:04:44.028Z", "__v": 0 }, { "_id": "63aeaa24f5f1af7f03dc6f48", "user": "63adb3ea747342cfad673030", "title": "My First Title", "description": "This is the description of my first title", "tag": "Personal", "date": "2022-12-30T09:06:44.121Z", "__v": 0 } ] const [notes, setNotes] = useState(notesInitial)

return( <NoteContext.Provider value={{notes, setNotes}}>

{props.children}
</NoteContext.Provider>

)

} export default NoteState;` But getting the error 'children' is missing in props validation react/prop-types Anybody help me to fix this issue. This is in Video 61

nirmalsinghoo7 commented 1 year ago

Getting same issue in Alert.js, Noteitem.js Screenshot at Jan 02 20-43-01

nirmalsinghoo7 commented 1 year ago

It's solved after install proptypes Here is updated code of Notestate.js

`import React, {useState} from 'react'; import NoteContext from "./noteContext"; import PropTypes from 'prop-types'

const NoteState = (props) => { const notesInitial = [ { "_id": "63aea9ac4dba234bd0ea172b", "user": "63adb3ea747342cfad673030", "title": "My First Updatedfdsf", "description": "Updated This is the descrsdfiption ofsdfsd my first title", "tag": "Personal", "date": "2022-12-30T09:04:44.028Z", "v": 0 }, { "_id": "63aeaa24f5f1af7f03dc6f48", "user": "63adb3ea747342cfad673030", "title": "My First Title", "description": "This is the description of my first title", "tag": "Personal", "date": "2022-12-30T09:06:44.121Z", "__v": 0 }, { "_id": "63aeaa27f5f1af7f03dc6f4c", "user": "63adb3ea747342cfad673030", "title": "My First Tisdfsdftle", "description": "This is the description ofsdfsd my first title", "tag": "Personal", "date": "2022-12-30T09:06:47.421Z", "v": 0 }, { "_id": "63aeaa2df5f1af7f03dc6f4e", "user": "63adb3ea747342cfad673030", "title": "My First Tisdfsdft32le", "description": "This is the descrsdfiption ofsdfsd my first title", "tag": "Personal", "date": "2022-12-30T09:06:53.183Z", "v": 0 }, { "_id": "63aec8e4b8faeb5ae11aa33d", "user": "63adb3ea747342cfad673030", "title": "My another note", "description": "This is the descrsdfiption ofsdfsd my first title", "tag": "General", "date": "2022-12-30T11:17:56.419Z", "__v": 0 }, { "_id": "63aecab0c20fe7f7357dc506", "user": "63adb3ea747342cfad673030", "title": "My another note", "description": "This is the descrsdfiption ofsdfsd my first title", "tag": "General", "date": "2022-12-30T11:25:36.539Z", "v": 0 }, { "_id": "63b2a0e6d62d46962557c88c", "user": "63adb3ea747342cfad673030", "title": "My another note", "description": "This is the descrsdfiption ofsdfsd my first title", "tag": "General", "date": "2023-01-02T09:16:22.607Z", "__v": 0 }, { "_id": "63b403806f83f8387ab7d479", "user": "63adb3ea747342cfad673030", "title": "Testing note today birthday", "description": "Birthday note today special", "tag": "Birthday", "date": "2023-01-03T10:29:20.738Z", "__v": 0 } ] const [notes, setNotes] = useState(notesInitial)

return( <NoteContext.Provider value={{notes, setNotes}}>

{props.children}
</NoteContext.Provider>

)

}

NoteState.propTypes = { children: PropTypes.string }

export default NoteState;`