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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b4498f070f
commit
7b31a1c6b6
40
desktop/plugins/public/headless-demo/index.tsx
Normal file
40
desktop/plugins/public/headless-demo/index.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* 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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user