SHARE
TWEET

Untitled

a guest Jun 27th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. document-id =>
  2.     item1 => {detail: "value", title: "value", image: "value}
  3.     item2 => {detail: "value", title: "value", image: "value}
  4.     ...
  5.      
  6. const [data, setData] = useState({});
  7.  
  8. useEffect(() => {
  9.   firebase.getDocument("path-to-document").then(section => {
  10.     if (section) {
  11.       setPanels(section.data());
  12.     }
  13.   });
  14. }, []);
  15.  
  16. const handleChange = (id, data) => {
  17.   const payload = data;
  18.   payload[id] = { ...panels[id], ...data };
  19.   setData(payload);
  20. }
  21.  
  22. return (<div>
  23.   {Object.keys(data).map((key) => <Card
  24.     data={data[key]}
  25.     onChange={handleChange} />)}
  26. </div>);
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