Skip to content

Instantly share code, notes, and snippets.

View olajohn-ajiboye's full-sized avatar

Ola John Ajiboye olajohn-ajiboye

View GitHub Profile
// context
import React, { useState } from 'react'
import { storeProducts, detailProduct } from './assets/data'
const ProductContext = React.createContext()
const ProductProvider = (props) => {
const [products, setProducts] = useState(storeProducts);
const [productDetails, setProductDetails] = useState(detailProduct)
console.log(products)
import React, { useContext } from 'react'
import Recipe from './Recipe'
import RecipeSearch from './RecipeSearch'
import { RecipeContext } from '../context/index'
export default function RecipeList() {
const appContext = useContext(RecipeContext)
const { showHomeButton, recipes, handleReturnHome } = appContext
return (
<>
import React, { useState, useEffect } from 'react'
const RecipeContext = React.createContext()
const apiKey = `7cdab426afc366070dab735500555521`
const RecipeProvider = (props) => {
let url = `https://www.food2fork.com/api/search?key=${apiKey}`
const [showHomeButton, setShowHomeButton] = useState(false)
const [recipes, setRecipes] = useState([])
const [loading, setLoading] = useState(true)
import React, { useState, useEffect } from 'react';
import RecipeList from './components/RecipeList';
import './App.css'
function App() {
// remeber to replace key
const apiKey = `36920f6651c9cd9d91a6c3205cabaa19`
let url = `https://www.food2fork.com/api/search?key=${apiKey}`
const [showHomeButton, setShowHomeButton] = useState(false)
const [recipes, setRecipes] = useState([])
@olajohn-ajiboye
olajohn-ajiboye / .js
Created July 4, 2019 15:17
UseEffect experiment
import React, { useState, useEffect } from 'react';
import RecipeList from './components/RecipeList'
import RecipeDetails from './components/RecipeDetails'
function App() {
const apiKey = `36920f6651c9cd9d91a6c3205cabaa19`
let url = `https://www.food2fork.com/api/search?key=${apiKey}`
const [showHomeButton, setShowHomeButton] = useState(false)
const [recipes, setRecipes] = useState([])
const [loading, setLoading] = useState(true)
import React, { useState } from 'react'
export default function Recipe({ recipe }) {
const { image_url, publisher, title, recipe_id } = recipe
const [showInfo, setShowInfo] = useState(false)
const [recipeDetails, setRecipeDetails] = useState([])
const { ingredients, social_rank } = recipeDetails
const handleShowInfo = async (e) => {
const { id } = e.target.dataset
import React, { useState, useEffect } from 'react';
import RecipeList from './components/RecipeList'
import RecipeDetails from './components/RecipeDetails'
function App() {
const url = `https://api.myjson.com/bins/t7szj`
const [recipes, setRecipes] = useState([])
const [loading, setLoading] = useState(true)
import React, { useState, useEffect } from 'react';
import RecipeList from './components/RecipeList
function App() {
const url = useState(`https://api.myjson.com/bins/t7szj`)
const [recipes, setRecipes] = useState([])
const fetchRecipe = async () => {
const recipeData = await fetch(url)
const { recipes } = await recipeData.json()
@olajohn-ajiboye
olajohn-ajiboye / .js
Created June 29, 2019 05:52
Class component
import React, { Component } from 'react'
import RecipeList from './components/RecipeList
export default class test extends Component {
constructor(props) {
super(props)
this.state = {
apiResponse: [],
}
}
@olajohn-ajiboye
olajohn-ajiboye / README.md
Created June 9, 2019 09:00 — forked from sidorares/README.md
node.js conventions and best practices

Node.JS best practices and conventions

This is not about JS style

Advice: if you have style guide / policy, apply it automatically ( in the editor or git hook ) https://github.com/jshint/fixmyjs

Collection of (mostly) JS styles (pick one you like or write another one if none fits you)