Clean code and pretty

This commit is contained in:
Sambo Chea 2020-06-04 09:51:56 +07:00
parent ebe310266c
commit 78cfd6db95

View File

@ -1,6 +1,6 @@
import React from 'react'
const BaseContext = React.createContext({ base: 'Context' })
const BaseContext = React.createContext({base: 'Context'})
/**
* Component : BaseContextProvider
@ -23,30 +23,30 @@ class BaseContextProvider extends React.Component {
render() {
const contextReturn = this.getContextReturnValue()
const Context = this.getContext()
const { children } = this.props
const {children} = this.props
return <Context.Provider value={contextReturn}>{children}</Context.Provider>
}
}
export const baseContextWrap = (Provider) => {
return (Component) => (props) => <Provider children={<Component {...props} />} />
return (Component) => (props) => <Provider children={<Component {...props} />}/>
}
export function baseUseContext(context) {
return function() {
return React.useContext(context)
}
export function baseUseContext(context) {
return function () {
return React.useContext(context)
}
}
export function baseWithContext(context, contextPassPropKey) {
const Consumer = context.Consumer
return (Component) => (props) => (
<Consumer>
export function baseWithContext(context, contextPassPropKey) {
const Consumer = context.Consumer
return (Component) => (props) => (
<Consumer>
{(contextValue) => (
<Component {...{ ...props, [contextPassPropKey]: contextValue }} />
)}
</Consumer>
<Component {...{...props, [contextPassPropKey]: contextValue}} />
)}
</Consumer>
)
}