forked from crowetic/commerce
Context Performance
This commit is contained in:
parent
f6beae6e38
commit
2da59ba533
@ -1,6 +1,6 @@
|
|||||||
import { FC, useEffect, useState, useCallback } from 'react'
|
import { FC, useEffect, useState, useCallback } from 'react'
|
||||||
import { validate } from 'email-validator'
|
import { validate } from 'email-validator'
|
||||||
import { Info } from'@components/icons'
|
import { Info } from '@components/icons'
|
||||||
import { useUI } from '@components/ui/context'
|
import { useUI } from '@components/ui/context'
|
||||||
import { Logo, Button, Input } from '@components/ui'
|
import { Logo, Button, Input } from '@components/ui'
|
||||||
import useSignup from '@lib/bigcommerce/use-signup'
|
import useSignup from '@lib/bigcommerce/use-signup'
|
||||||
@ -59,7 +59,7 @@ const ForgotPassword: FC<Props> = () => {
|
|||||||
<div className="text-red border border-red p-3">{message}</div>
|
<div className="text-red border border-red p-3">{message}</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Input placeholder="Email" onChange={setEmail} />
|
<Input placeholder="Email" onChange={setEmail} type="email" />
|
||||||
<div className="pt-2 w-full flex flex-col">
|
<div className="pt-2 w-full flex flex-col">
|
||||||
<Button
|
<Button
|
||||||
variant="slim"
|
variant="slim"
|
||||||
|
@ -70,8 +70,8 @@ const LoginView: FC<Props> = () => {
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<Input placeholder="Email" onChange={setEmail} />
|
<Input placeholder="Email" onChange={setEmail} type="email" />
|
||||||
<Input placeholder="Password" onChange={setPassword} />
|
<Input placeholder="Password" onChange={setPassword} type="password" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
variant="slim"
|
variant="slim"
|
||||||
|
@ -69,8 +69,8 @@ const SignUpView: FC<Props> = () => {
|
|||||||
)}
|
)}
|
||||||
<Input placeholder="First Name" onChange={setFirstName} />
|
<Input placeholder="First Name" onChange={setFirstName} />
|
||||||
<Input placeholder="Last Name" onChange={setLastName} />
|
<Input placeholder="Last Name" onChange={setLastName} />
|
||||||
<Input placeholder="Email" onChange={setEmail} />
|
<Input placeholder="Email" onChange={setEmail} type="email" />
|
||||||
<Input placeholder="Password" onChange={setPassword} />
|
<Input placeholder="Password" onChange={setPassword} type="password" />
|
||||||
<span className="text-accents-8">
|
<span className="text-accents-8">
|
||||||
<span className="inline-block align-middle ">
|
<span className="inline-block align-middle ">
|
||||||
<Info width="15" height="15" />
|
<Info width="15" height="15" />
|
||||||
|
@ -20,15 +20,17 @@ const Input: React.FC<Props> = (props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<input
|
<label>
|
||||||
className={rootClassName}
|
<input
|
||||||
onChange={handleOnChange}
|
className={rootClassName}
|
||||||
autoComplete="off"
|
onChange={handleOnChange}
|
||||||
autoCorrect="off"
|
autoComplete="off"
|
||||||
autoCapitalize="off"
|
autoCorrect="off"
|
||||||
spellCheck="false"
|
autoCapitalize="off"
|
||||||
{...rest}
|
spellCheck="false"
|
||||||
/>
|
{...rest}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { FC } from 'react'
|
import React, { FC, useMemo } from 'react'
|
||||||
import { ThemeProvider } from 'next-themes'
|
import { ThemeProvider } from 'next-themes'
|
||||||
import { SSRProvider, OverlayProvider } from 'react-aria'
|
import { SSRProvider, OverlayProvider } from 'react-aria'
|
||||||
|
|
||||||
@ -144,18 +144,21 @@ export const UIProvider: FC = (props) => {
|
|||||||
const setModalView = (view: MODAL_VIEWS) =>
|
const setModalView = (view: MODAL_VIEWS) =>
|
||||||
dispatch({ type: 'SET_MODAL_VIEW', view })
|
dispatch({ type: 'SET_MODAL_VIEW', view })
|
||||||
|
|
||||||
const value = {
|
const value = useMemo(
|
||||||
...state,
|
() => ({
|
||||||
openSidebar,
|
...state,
|
||||||
closeSidebar,
|
openSidebar,
|
||||||
openDropdown,
|
closeSidebar,
|
||||||
closeDropdown,
|
openDropdown,
|
||||||
openModal,
|
closeDropdown,
|
||||||
closeModal,
|
openModal,
|
||||||
setModalView,
|
closeModal,
|
||||||
openToast,
|
setModalView,
|
||||||
closeToast,
|
openToast,
|
||||||
}
|
closeToast,
|
||||||
|
}),
|
||||||
|
[state]
|
||||||
|
)
|
||||||
|
|
||||||
return <UIContext.Provider value={value} {...props} />
|
return <UIContext.Provider value={value} {...props} />
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user