dekiru2022 / dekiru

0 stars 0 forks source link

プッシュ機能を追加 #39

Closed dekiru2022 closed 2 years ago

dekiru2022 commented 2 years ago

ソースレビュします(我喜屋)

dekiru2022 commented 2 years ago

参考1:https://bestofreactjs.com/repo/igorprado-react-notification-system-react-notification 参考2:https://note.crohaco.net/2018/react-libraries/ defaultRoute.js

import NotificationSystem from 'react-notification-system';
 useEffect(() => {
    const subscription = API.graphql(graphqlOperation(onCreateNotice)).subscribe({
      next: (eventData) => {
        const URL = eventData.value.data.onCreateNotice.linkDestinationUrl;
        console.log(URL);
        ref.current.addNotification({
          title,
          level,
          position,
          uid,
          autoDismiss,
          action: {
            label: "相談者に会う",
            callback: () => window.open(URL)
          }
        });
      }
    });
    return () => subscription.unsubscribe();
  })