From 0bdabbe7048b6aee899e0feaec8d655a15417c5f Mon Sep 17 00:00:00 2001 From: Kageetai Date: Wed, 22 Feb 2023 15:51:31 +0100 Subject: [PATCH] adjust default value for `createContext` example passing in `undefined` here throws the following error: ``` TS2345: Argument of type 'undefined' is not assignable to parameter of type 'App'. ``` I propose this type cast instead, even though not the most elegant solution, it avoids the error, as the context is already set in initialization of the React context. --- docs/getting-started/react.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting-started/react.md b/docs/getting-started/react.md index c7d22e9a..b16e5dde 100644 --- a/docs/getting-started/react.md +++ b/docs/getting-started/react.md @@ -110,7 +110,7 @@ Another alternative is to create a React context for the app to make it globally import * as React from "react"; import { App } from 'obsidian'; - export const AppContext = React.createContext(undefined); + export const AppContext = React.createContext({} as App); ``` 1. Wrap the `ReactView` with a context provider and pass the app as the value.