• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript react.createContext函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中react.createContext函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createContext函数的具体用法?TypeScript createContext怎么用?TypeScript createContext使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了createContext函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1:

import * as React from 'react'
import { ChartConfig } from 'charts/ChartConfig'
import { ChartView } from 'charts/ChartView'
import { VNode } from 'charts/Util'

export interface ChartViewContextType {
    chart: ChartConfig
    chartView: ChartView
    baseFontSize: number
    isStatic: boolean
    addPopup: (vnode: VNode) => void,
    removePopup: (vnode: VNode) => void
}

const ChartViewContext: React.Context<ChartViewContextType> = React.createContext({}) as any
export { ChartViewContext }
开发者ID:OurWorldInData,项目名称:owid-grapher,代码行数:16,代码来源:ChartViewContext.ts


示例2: createContext

/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License;
 * you may not use this file except in compliance with the Elastic License.
 */

import { createContext } from 'react';

interface UMRefreshContext {
  lastRefresh: number;
}

const defaultContext: UMRefreshContext = {
  lastRefresh: 0,
};

export const UptimeRefreshContext = createContext(defaultContext);
开发者ID:,项目名称:,代码行数:17,代码来源:


示例3: isKibanaContext

import { IndexPattern } from 'ui/index_patterns';

export interface KibanaContextValue {
  combinedQuery: any;
  currentIndexPattern: IndexPattern;
  currentSavedSearch: any;
  indexPatterns: any;
  kbnBaseUrl: string;
  kibanaConfig: any;
}

export type SavedSearchQuery = object;

// Because we're only getting the actual contextvalue within a wrapping angular component,
// we need to initialize here with `null` because TypeScript doesn't allow createContext()
// without a default value. The nullable union type takes care of allowing
// the actual required type and `null`.
export type NullableKibanaContextValue = KibanaContextValue | null;
export const KibanaContext = React.createContext<NullableKibanaContextValue>(null);

export function isKibanaContext(arg: any): arg is KibanaContextValue {
  return (
    arg.combinedQuery !== undefined &&
    arg.currentIndexPattern !== undefined &&
    arg.currentSavedSearch !== undefined &&
    arg.indexPatterns !== undefined &&
    typeof arg.kbnBaseUrl === 'string' &&
    arg.kibanaConfig !== undefined
  );
}
开发者ID:elastic,项目名称:kibana,代码行数:30,代码来源:kibana_context.ts


示例4: requestUIKeydown

export const defaultFullScreenState: FullScreenNavState = {
  initial: true,
  visibleComponentLeft: '',
  visibleComponentRight: '',
  inventoryItems: null,
  equippedItems: null,
  containerIdToDrawerInfo: {},
  stackGroupIdToItemIDs: {},
  myTradeItems: null,
  myTradeState: SecureTradeState.None,
  tabsLeft: defaultTabsLeft,
  tabsRight: defaultTabsRight,
  invBodyDimensions: { width: 0, height: 0 },
};

export const FullScreenContext = React.createContext(defaultFullScreenState);

export function requestUIKeydown() {
  const shouldFullscreenListen = false;
  events.fire('hudfullscreen-shouldListenKeydown', shouldFullscreenListen);
}

export function releaseUIKeydown() {
  const shouldFullscreenListen = true;
  events.fire('hudfullscreen-shouldListenKeydown', shouldFullscreenListen);
}

export function isRightOrLeftItem(gearSlots: GearSlotDefRef.Fragment[]) {
  if (gearSlots.length === 1) {
    const firstGearSlotId = gearSlots[0].id;
    return _.includes(firstGearSlotId.toLowerCase(), 'right') ||
开发者ID:codecorsair,项目名称:Camelot-Unchained,代码行数:31,代码来源:utils.ts


示例5:

  refetch: () => {},
  statusCode: 0,
};

export const defaultContextState: HUDContextState = {
  skills: {
    ...defaultQueryResultInfo,
    data: [],
  },
  itemDefRefs: {
    ...defaultQueryResultInfo,
    data: [],
  },
};

export const HUDContext = React.createContext(defaultContextState);

export const skillsQuery = `
  {
    myCharacter {
      skills {
        id
        name
        icon
        notes
        tracks
      }
    }
  }
`;
开发者ID:csegames,项目名称:Camelot-Unchained,代码行数:30,代码来源:context.ts


示例6: updateCurrentDocument

  updateCurrentDocument(sender?: Partial<PubDocument>): void;
  adjustObjectLayer(sender: LayerMutationDelta): void;
  setStartModalVisible(visible: boolean): void;
  setNewAccountModalVisible(visible: boolean): void;
  setLoginModalVisible(visible: boolean): void;
  setAboutModalVisible(visible: boolean): void;
  setCurrentDocument: React.Dispatch<PubDocument | null>;
}

export interface PubAppState {
  actions: PubActions;
  currentDocument: PubDocument | null;
  clipboardContents: PubShape | null;
  dataLoaded: boolean;
  documents: Array<PubDocument>;
  layersPanelVisible: boolean;
  selectedObject: PubShape | null;
  user: PubUser | null;
  zoom: number;
  startModalVisible: boolean;
  loginModalVisible: boolean;
  newAccountModalVisible: boolean;
  openDocumentModalVisible: boolean;
  aboutModalVisible: boolean;
  newDocumentModalVisible: boolean;
}

export const StateContext = React.createContext<PubAppState>(
  null as PubAppState
);
开发者ID:carlospaelinck,项目名称:publications-js,代码行数:30,代码来源:app-state.ts


示例7: createContext

import { createContext } from "react";

export interface IMessage {
  text: string;
  onUndo?: () => void;
}
export const MessageContext = createContext(undefined);

export * from "./MessageManager";
export default MessageContext.Consumer;
开发者ID:elwoodxblues,项目名称:saleor,代码行数:10,代码来源:index.ts


示例8:

import * as React from 'react'
import { Admin } from './Admin'

const AdminAppContext: React.Context<{ admin: Admin }> = React.createContext({}) as any
export { AdminAppContext }
开发者ID:OurWorldInData,项目名称:owid-grapher,代码行数:5,代码来源:AdminAppContext.ts


示例9: useContext

/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License;
 * you may not use this file except in compliance with the Elastic License.
 */

import { ApolloClient } from 'apollo-client';
import { createContext, useContext } from 'react';

/**
 * This is a temporary provider and hook for use with hooks until react-apollo
 * has upgraded to the new-style `createContext` api.
 */

export const ApolloClientContext = createContext<ApolloClient<{}> | undefined>(undefined);

export const useApolloClient = () => {
  return useContext(ApolloClientContext);
};
开发者ID:elastic,项目名称:kibana,代码行数:19,代码来源:apollo_context.ts


示例10:

import Kefir, { Pool } from 'kefir';
import { Action } from 'redux';
import { createContext } from 'react';

const { Provider, Consumer } = createContext<Pool<Action, Error>>(Kefir.pool());

export { Provider, Consumer };
开发者ID:valtech-nyc,项目名称:brookjs,代码行数:7,代码来源:context.ts



注:本文中的react.createContext函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript react.createElement函数代码示例发布时间:2022-05-25
下一篇:
TypeScript react.createClass函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap