GroceriStar / groceristar-fetch

json arrays for Food Tech projects
https://groceristar.github.io/groceristar-fetch/
GNU General Public License v3.0
8 stars 18 forks source link

update connection with fetch plugin at React projects #118

Open atherdon opened 5 years ago

atherdon commented 5 years ago

Based on Vadim comment

Yes. I have done publish npm. After update to v1.1.27 We have a problem in react-shopping-list-template. I need change imports from

import gf from '@groceristar/groceristar-fetch/groceristar';

to this

const { groceristar } = require('@groceristar/groceristar-fetch'); 

1) Recipe App https://github.com/ChickenKyiv/recipe-app-react-native/blob/master/src/components/Directions/index.js#L7 https://github.com/ChickenKyiv/recipe-app-react-native/blob/master/src/components/FreeRecipes/index.js#L6 https://github.com/ChickenKyiv/recipe-app-react-native/blob/master/src/components/GroceryList/GroceryList.js#L8 https://github.com/ChickenKyiv/recipe-app-react-native/blob/master/src/components/GroceryList/index.js#L12 https://github.com/ChickenKyiv/recipe-app-react-native/blob/master/src/components/GroceryListSettings/index.js#L12

https://github.com/GroceriStar/react-native-shoppin-list/blob/components-structure/src/components/layouts/GroceryList.js#L5 https://github.com/GroceriStar/react-native-shoppin-list/blob/components-structure/src/components/layouts/IngredientDetails.js#L7 https://github.com/GroceriStar/react-native-shoppin-list/blob/components-structure/src/components/layouts/Todo.js#L5

https://github.com/GroceriStar/react-native-shoppin-list/blob/components-structure/src/HelperFunctions.js


https://github.com/GroceriStar/showcase https://github.com/GroceriStar/calendar https://github.com/ChickenKyiv/recipe-search-react https://github.com/GroceriStar/react-only-intern-23

https://github.com/GroceriStar/react-shopping-list-template

https://github.com/ChickenKyiv/recipe-box

atherdon commented 5 years ago

@vadim9999 can you, by using code example that you've made here https://github.com/GroceriStar/calendar/pull/69/commits/d1bd32f03204da58aada4d74fa7ce04d7274db92 - create a great explanation about what we should do for our team members?

vadim9999 commented 5 years ago

In src need create folder selectors with Selector.js. There you should add imports that used in current project and create methods to get data. For example, fetch conected in component like this

//ColumnRender.js
import data from "@groceristar/groceristar-fetch/mealCalendar";

var result = mealCalendar.getDishByWeek("week1");

In latest version of fetch need to rebase import from import data from "@groceristar/groceristar-fetch/mealCalendar"; to import { mealCalendar } from "@groceristar/groceristar-fetch";

//Selector.js
import { mealCalendar } from "@groceristar/groceristar-fetch";

function getDish(week){
      return mealCalendar.getDishByWeek(week);
  }

Now in ColumnRender

//ColumnRender.js
import { getDish } from "../selectors/Selector.js";

var result = getDish("week1");
atherdon commented 5 years ago

as sample https://github.com/GroceriStar/calendar/blob/master/src/components/selectors/selector.js https://github.com/GroceriStar/calendar/blob/master/src/components/Calendar/Meal.js