Files
flipper/desktop/plugins/public/headless-demo/index.tsx
Andrey Goncharov 7b31a1c6b6 Add headless-demo plugin and its usage example
Summary:
Next steps:
1. Refactor it TS for consistency
2. Remove it in favor of tic-tac-toe integration

Reviewed By: mweststrate

Differential Revision: D36102002

fbshipit-source-id: 7dc930f67bed636159a2ec433d7405ab6ee09f97
2022-05-10 05:13:24 -07:00

41 lines
822 B
TypeScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import React from 'react';
import {createState, Layout, FlipperPluginInstance} from 'flipper-plugin';
export function API(
pluginInstance: FlipperPluginInstance<typeof devicePlugin>,
) {
return {
increment: pluginInstance.increment,
};
}
export function devicePlugin() {
const data = createState(0);
const increment = (step: number = 1) => {
const newVal = data.get() + step;
data.set(newVal);
return newVal;
};
return {increment};
}
export function Component() {
return (
<Layout.ScrollContainer>
I am a new shiny headless plugin
</Layout.ScrollContainer>
);
}