Hi, need me little help with use context. Exactly I wish use data from
function noviPodaci() {
fetch("localhost/posts.json")
.then(response => {
return response.json();
})
.then(json => {
console.log("parsed json iz funkcije noviPodaci", json);
alert([json.name, json.id, json.email]);
})
.catch(function(ex) {
console.log("parsing failed", ex);
});
}
to
import React from "react";
import "whatwg-fetch";
export const CTX = React.createContext();
export default function Store(props) {
const statHooks = React.useState({ color: colors, naziv: ime, new: "data of function });
return (
<CTX.Provider value={statHooks}>
<div>{props.children}</div>
</CTX.Provider>
);
}
How do that?
You can see all code at codesandbox.io/s/naughty-hypatia-swsqm
Thanks
Mr.Miodrag
Hi, need me little help with use context. Exactly I wish use data from
function noviPodaci() { fetch("localhost/posts.json") .then(response => { return response.json(); }) .then(json => { console.log("parsed json iz funkcije noviPodaci", json); alert([json.name, json.id, json.email]); }) .catch(function(ex) { console.log("parsing failed", ex); }); } to import React from "react"; import "whatwg-fetch";
export const CTX = React.createContext();
export default function Store(props) { const statHooks = React.useState({ color: colors, naziv: ime, new: "data of function });
return ( <CTX.Provider value={statHooks}> <div>{props.children}</div> </CTX.Provider> ); }
How do that? You can see all code at codesandbox.io/s/naughty-hypatia-swsqm Thanks Mr.Miodrag