Correct use selector (#515)

This commit is contained in:
mrdrogdrog 2020-08-30 21:24:34 +02:00 committed by GitHub
parent 971421925a
commit a41d3d1515
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 74 additions and 205 deletions

View file

@ -1,3 +1,5 @@
import equal from 'fast-deep-equal'
import React from 'react'
import { useSelector } from 'react-redux'
import { ApplicationState } from '../../../redux'
@ -9,7 +11,7 @@ export interface BrandingProps {
}
export const Branding: React.FC<BrandingProps> = ({ inline = false }) => {
const branding = useSelector((state: ApplicationState) => state.config.branding)
const branding = useSelector((state: ApplicationState) => state.config.branding, equal)
const showBranding = !!branding.name || !!branding.logo
return (

View file

@ -7,11 +7,11 @@ export interface DocumentTitleProps {
}
export const DocumentTitle: React.FC<DocumentTitleProps> = ({ title }) => {
const branding = useSelector((state: ApplicationState) => state.config.branding)
const brandingName = useSelector((state: ApplicationState) => state.config.branding.name)
useEffect(() => {
document.title = `${title ? title + ' - ' : ''}CodiMD ${branding.name ? ` @ ${branding.name}` : ''}`
}, [branding, title])
document.title = `${title ? title + ' - ' : ''}CodiMD ${brandingName ? ` @ ${brandingName}` : ''}`
}, [brandingName, title])
return null
}

View file

@ -1,3 +1,4 @@
import equal from 'fast-deep-equal'
import React from 'react'
import { useSelector } from 'react-redux'
import { Link } from 'react-router-dom'
@ -8,7 +9,7 @@ import { ForkAwesomeIcon } from '../fork-awesome/fork-awesome-icon'
import { ShowIf } from '../show-if/show-if'
export const MotdBanner: React.FC = () => {
const bannerState = useSelector((state: ApplicationState) => state.banner)
const bannerState = useSelector((state: ApplicationState) => state.banner, equal)
const dismissBanner = () => {
setBanner({ ...bannerState, show: false })