0.1.3 • Published 3 years ago

@kaercher/contentful v0.1.3

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

@kaercher/contentful

helper hooks to get Kärcher Contenful content

Usage

// import the lib
const contentful = require('@kaercher/contentful');

// configure the hook passing the secrets (possible from .env)
const { useGetFaqTopic, useSearchFaq } = useContentful(
    Config.CONTENTFUL_URL,
    Config.CONTENTFUL_TOKEN,
);

// all hooks will return this three props. data is typed according to the expected return type
// if you need quick valid params for testing use: ('3hmEGrYQf7RjV63MfUP2Xj', 'de-DE');
const { data, isLoading, isError } = useGetFaqTopic(topicId, locale);

 if (isLoading) {
    return (
        <ActivityIndicator style={styles.indicator} size={indicatorSize} />
    );
  }

  if (isError) {
    return (
        <Text>{'Error getting faq topic'}</Text>
    );
  }

  // we are sure we have data, use you need now∏∏
  return (
      <Text>{data[0].question}</Text>
  );
// we can also search if we like
  const { data, isLoading, isError } = useSearchFaqs('Abfällen', 'de-DE');
0.1.3

3 years ago

0.1.2

3 years ago

0.1.0

3 years ago