Home > Software design >  how can i use what i imported in another component in context API with arrow function
how can i use what i imported in another component in context API with arrow function

Time:06-05

pls i wanted to use placeInfo,reviews,detailsInfo,news coming from data file. instead of putting value='hello' [import { placeInfo, reviews, detailsInfo, news } from '../data';<InfoContext.Provider value={placeInfo,reviews,detailsInfo,news} >][1]i doubt if i can use it direct like this value={placeInfo,reviews,detailsInfo,news} which is giving me error or i should put it in var

CodePudding user response:

Wrap the value in an object like this value={{placeInfo, reviews, detailsInfo, news}}

or create the object on a separate line like this:

const value = {
   placeInfo,
   reviews,
   detailsInfo,
   news
};

Then pass it as value={value}

  • Related