Learn React Hooks and Context API by building a Recipe Search App (Part 2)
This is the second part of the series in learning React Hooks and the Context API. In the first part we learn the basics of useState, built the first parts of the Recipe Search application. The full code can be found on github
Overview of what we'll...
mongopark.hashnode.dev
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