React全局变量

React全局变量容器

// Provider
import { createContext } from 'react'
export const TestContext = createContext(null)
export const ContainerContext = createContext(null)


// 设置全局包裹
import { TestContext } from './Provider'
const confDrawer: any = usekef(null)
...
return (




// 使用
import { TestContext } from '../../Provider';
const { confDrawerShow }= useContext(TestContext)
const onFn = () => {
  confDrawerShow('edit',{ data: xxxx })
}

你可能感兴趣的:(React,javascript,react.js,开发语言)