0

i'm wondering if there's any way to call API methods without inject each component ?

somthing like providing a function that will call intl.formatMessage for example

export function t(id,defaultmessage){
console.log("Called ",id,defaultmessage);
return intl.formatMessage(
{
  id: id,
  defaultMessage: defaultmessage
 }
)
}
M1M6
  • 915
  • 3
  • 17
  • 33

1 Answers1

0

I would look into a state management library such as Redux. The data would then be passed into each component as a property, instead of having an API call in each component.

Chad
  • 608
  • 5
  • 15
  • what i mean is how to call react-intl APi methods, which already exists inside react-intl, but the way they call them is by injection props in other component, which i don't like to implement it – M1M6 Dec 23 '16 at 11:55