Start abstractions for the guide

Summary:
This is the third diff for M3

- Started abstractions to remove repetitive code as a part of M3
- Implemented a new abstracted component in GuideAnserScreen and removed PluginErrored.tsx to integrate it here.
- Using a map object that maps a string to function. Here I have used helper functions to get each screens context as first class members.
- The map is global and is populated globally (as discussed) and we invoke the required function based on the state we are at from GuideAnswerScreen.

Reviewed By: mweststrate

Differential Revision: D30772236

fbshipit-source-id: f8fc175c6d308e2f72c5f6ce826f70245ad46797
This commit is contained in:
Ananya Arun
2021-09-10 06:26:59 -07:00
committed by Facebook GitHub Bot
parent da9511a5bf
commit 0816f73d07

View File

@@ -0,0 +1,17 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
export function assertNotNull<T extends any>(
value: T,
message: string = 'Unexpected null/undefined value found',
): asserts value is Exclude<T, undefined | null> {
if (value === null || value === undefined) {
throw new Error(message);
}
}