I use the useContext method in my React Layout component and get this error that Type ‘StringConstructor’ is not assignable to type ‘ReactNode’.
I wrote Layout Component such as :
function Layout({ children }: { children: React.ReactNode }) {
const layoutcontext = useContext(LayoutContext);
return (
<div id="company-info-wraper" className="d-none d-lg-block">
<div className=" text-center">
<p id="company-name">{layoutcontext.Organization} </p>
<p id="package-name" style={{ fontWeight: "600" }}> {layoutcontext.Name } </p>
<p id="package-code">({layoutcontext.Code }) ( {layoutcontext.Version })</p>
</div>
</div>
)
}
LayoutContext :
import { createContext } from "react";
const LayoutContext = createContext({
Organization: String,
Name: String,
Code: String,
Version: String
});
export default LayoutContext;
What is the problem? How can I fix this?