skip to Main Content

Reactjs – How To Use useContext react

import React from 'react' import ReactDOM from 'react-dom' import { useContext } from 'react' const konteks = React.createContext(null); function components(){ return( <konteks.Provider value="hello world"> <MyComponent /> </konteks.Provider> ); } function MyComponent(){ const getcontext = useContext(konteks); return( <div>{getcontext}</div> ); } const…

VIEW QUESTION

Reactjs – useState Hook react

in useState hook when the setState is called it will initializes the state with a new value i have the example of code below : import React from 'react' import ReactDOM from 'react-dom/client' import { useState } from 'react' function…

VIEW QUESTION

Reactjs – In prop passing through children, how to align type to it

Problem: when I use below expression, IDE alerts typescript syntax error. I think typescript expects children to be assigned as ReactNode not as Array<object>. ----/page.tsx/---- ... <TopBar>{[ {text:"career",href:"",class:"p-0 m-0"}, {text:"contact",href:"",class:"p-0 m-0"}, {text:"patient registry",href:"/patient_registry",class:"custom-outline p-1 rounded-2xl px-4 hover:bg-black hover:text-white"} ]}</TopBar> ...…

VIEW QUESTION
Back To Top
Search