Reorganised React imports

- we use ES6 `import` for all other imports so this standardizes the
  React package to also use import vs require
- merged with other imports from the react package if present
This commit is contained in:
Daniel Lockyer 2023-03-15 08:44:45 +01:00
parent 03b8715276
commit 42d9c3ea4d
No known key found for this signature in database
17 changed files with 18 additions and 37 deletions

View File

@ -1,3 +1,4 @@
import React from 'react';
import * as Sentry from '@sentry/react';
import TriggerButton from './components/TriggerButton';
import Notification from './components/Notification';
@ -13,8 +14,6 @@ import NotificationParser from './utils/notifications';
import {allowCompMemberUpgrade, createPopupNotification, getCurrencySymbol, getFirstpromoterId, getPriceIdFromPageQuery, getProductCadenceFromPrice, getProductFromId, getQueryPrice, getSiteDomain, isActiveOffer, isComplimentaryMember, isInviteOnlySite, isPaidMember, isSentryEventAllowed, removePortalLinkFromUrl} from './utils/helpers';
import {handleDataAttributes} from './data-attributes';
const React = require('react');
const DEV_MODE_DATA = {
showPopup: true,
site: Fixtures.site,

View File

@ -1,5 +1,5 @@
// Ref: https://reactjs.org/docs/context.html
const React = require('react');
import React from 'react';
const AppContext = React.createContext({
site: {},

View File

@ -1,3 +1,4 @@
import React from 'react';
import Frame from './Frame';
import AppContext from '../AppContext';
import NotificationStyle from './Notification.styles';
@ -7,8 +8,6 @@ import {ReactComponent as WarningIcon} from '../images/icons/warning-fill.svg';
import NotificationParser, {clearURLParams} from '../utils/notifications';
import {getPortalLink} from '../utils/helpers';
const React = require('react');
const Styles = () => {
return {
frame: {

View File

@ -1,3 +1,4 @@
import React from 'react';
import Frame from './Frame';
import {hasMode} from '../utils/check-mode';
import AppContext from '../AppContext';
@ -7,8 +8,6 @@ import PopupNotification from './common/PopupNotification';
import PoweredBy from './common/PoweredBy';
import {getSiteProducts, isInviteOnlySite, isCookiesDisabled, hasFreeProductPrice} from '../utils/helpers';
const React = require('react');
const StylesWrapper = ({member}) => {
return {
modalContainer: {

View File

@ -1,3 +1,4 @@
import React from 'react';
import Frame from './Frame';
import MemberGravatar from './common/MemberGravatar';
import AppContext from '../AppContext';
@ -11,8 +12,6 @@ import TriggerButtonStyle from './TriggerButton.styles';
import {isInviteOnlySite} from '../utils/helpers';
import {hasMode} from '../utils/check-mode';
const React = require('react');
const ICON_MAPPING = {
'icon-1': ButtonIcon1,
'icon-2': ButtonIcon2,

View File

@ -1,14 +1,12 @@
import AppContext from '../../AppContext';
import CloseButton from '../common/CloseButton';
import BackButton from '../common/BackButton';
import {useContext, useState} from 'react';
import React, {useContext, useState} from 'react';
import Switch from '../common/Switch';
import {getSiteNewsletters, hasMemberGotEmailSuppression} from '../../utils/helpers';
import ActionButton from '../common/ActionButton';
import {ReactComponent as CheckmarkIcon} from '../../images/icons/check-circle.svg';
const React = require('react');
function AccountHeader() {
const {brandColor, lastPage, onAction, t} = useContext(AppContext);
return (

View File

@ -1,10 +1,8 @@
import AppContext from '../../AppContext';
import {useContext, useEffect, useState} from 'react';
import React, {useContext, useEffect, useState} from 'react';
import {isPaidMember} from '../../utils/helpers';
import NewsletterManagement from '../common/NewsletterManagement';
const React = require('react');
export default function AccountEmailPage() {
const {member, onAction, site, t} = useContext(AppContext);

View File

@ -1,4 +1,4 @@
import {useContext, useState} from 'react';
import React, {useContext, useState} from 'react';
import AppContext from '../../AppContext';
import ActionButton from '../common/ActionButton';
import CloseButton from '../common/CloseButton';
@ -38,8 +38,6 @@ export const AccountPlanPageStyles = `
}
`;
const React = require('react');
function getConfirmationPageTitle({confirmationType}) {
if (confirmationType === 'changePlan') {
return 'Confirm subscription';

View File

@ -1,3 +1,4 @@
import React from 'react';
import AppContext from '../../AppContext';
import MemberAvatar from '../common/MemberGravatar';
import ActionButton from '../common/ActionButton';
@ -6,8 +7,6 @@ import BackButton from '../common/BackButton';
import InputForm from '../common/InputForm';
import {ValidateInputForm} from '../../utils/form';
const React = require('react');
export default class AccountProfilePage extends React.Component {
static contextType = AppContext;

View File

@ -1,4 +1,4 @@
import {useContext, useEffect, useState} from 'react';
import React, {useContext, useEffect, useState} from 'react';
import AppContext from '../../AppContext';
import {ReactComponent as ThumbDownIcon} from '../../images/icons/thumbs-down.svg';
import {ReactComponent as ThumbUpIcon} from '../../images/icons/thumbs-up.svg';
@ -9,8 +9,6 @@ import ActionButton from '../common/ActionButton';
import CloseButton from '../common/CloseButton';
import LoadingPage from './LoadingPage';
const React = require('react');
export const FeedbackPageStyles = `
.gh-portal-feedback {

View File

@ -1,5 +1,6 @@
import React from 'react';
import {ReactComponent as LoaderIcon} from '../../images/icons/loader.svg';
const React = require('react');
export default class LoadingPage extends React.Component {
render() {
return (

View File

@ -1,10 +1,9 @@
import React from 'react';
import ActionButton from '../common/ActionButton';
import CloseButton from '../common/CloseButton';
import AppContext from '../../AppContext';
import {ReactComponent as EnvelopeIcon} from '../../images/icons/envelope.svg';
const React = require('react');
export const MagicLinkStyles = `
.gh-portal-icon-envelope {
width: 44px;

View File

@ -1,12 +1,10 @@
import AppContext from '../../AppContext';
import {useContext, useState} from 'react';
import React, {useContext, useState} from 'react';
import Switch from '../common/Switch';
import {getSiteNewsletters} from '../../utils/helpers';
import ActionButton from '../common/ActionButton';
import {ReactComponent as LockIcon} from '../../images/icons/lock.svg';
const React = require('react');
function NewsletterPrefSection({newsletter, subscribedNewsletters, setSubscribedNewsletters}) {
const isChecked = subscribedNewsletters.some((d) => {
return d.id === newsletter?.id;

View File

@ -1,3 +1,4 @@
import React from 'react';
import ActionButton from '../common/ActionButton';
import AppContext from '../../AppContext';
import {ReactComponent as CheckmarkIcon} from '../../images/icons/checkmark.svg';
@ -6,7 +7,6 @@ import InputForm from '../common/InputForm';
import {getCurrencySymbol, getProductFromId, hasMultipleProductsFeature, isSameCurrency, formatNumber, hasMultipleNewsletters} from '../../utils/helpers';
import {ValidateInputForm} from '../../utils/form';
import NewsletterSelectionPage from './NewsletterSelectionPage';
const React = require('react');
export const OfferPageStyles = ({site}) => {
return `

View File

@ -1,3 +1,4 @@
import React from 'react';
import ActionButton from '../common/ActionButton';
import CloseButton from '../common/CloseButton';
// import SiteTitleBackButton from '../common/SiteTitleBackButton';
@ -5,8 +6,6 @@ import AppContext from '../../AppContext';
import InputForm from '../common/InputForm';
import {ValidateInputForm} from '../../utils/form';
const React = require('react');
export default class SigninPage extends React.Component {
static contextType = AppContext;

View File

@ -1,3 +1,4 @@
import React from 'react';
import ActionButton from '../common/ActionButton';
import AppContext from '../../AppContext';
import CloseButton from '../common/CloseButton';
@ -9,8 +10,6 @@ import {ValidateInputForm} from '../../utils/form';
import {getSiteProducts, getSitePrices, hasOnlyFreePlan, isInviteOnlySite, freeHasBenefitsOrDescription, hasOnlyFreeProduct, getFreeProductBenefits, getFreeTierDescription, hasFreeProductPrice, hasMultipleNewsletters, hasFreeTrialTier} from '../../utils/helpers';
import {ReactComponent as InvitationIcon} from '../../images/icons/invitation.svg';
const React = require('react');
export const SignupPageStyles = `
.gh-portal-back-sitetitle {
position: absolute;

View File

@ -1,14 +1,12 @@
import AppContext from '../../AppContext';
import ActionButton from '../common/ActionButton';
import {useContext, useEffect, useState} from 'react';
import React, {useContext, useEffect, useState} from 'react';
import {getSiteNewsletters} from '../../utils/helpers';
import setupGhostApi from '../../utils/api';
import NewsletterManagement from '../common/NewsletterManagement';
import CloseButton from '../common/CloseButton';
import {ReactComponent as WarningIcon} from '../../images/icons/warning-fill.svg';
const React = require('react');
function SiteLogo() {
const {site} = useContext(AppContext);
const siteLogo = site.icon;