SHARE
TWEET

Untitled

a guest Sep 12th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import apiGenerator from './apiGenerator';
  4.  
  5. function ComponentAPI({
  6.   api
  7. }) {
  8.   const [data, setData] = useState(null);
  9.   const [loading, setLoading] = useState(true);
  10.   useEffect(() => {
  11.     api.fetchData().then(setData);
  12.   }, []);
  13.  
  14.   return (loading ? 'Loading data...' : <DataComponent data={data} />);
  15. }
  16.  
  17. export default connect(state => ({ api: apiGenerator(state) }))(ComponentAPI);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top