Files
flipper/src/plugins/navigation/index.js
Benjamin Elo 4d774ba252 Added navigation plugin
Summary: Adding the auto-genrated scarf files from creating the Flipper navigation plugin. GK for this plugin is flipper-navigation.

Reviewed By: jknoxville, danielbuechele

Differential Revision: D16119841

fbshipit-source-id: 74e19c82dc95e73fe2ae06d1eb8cef2456b81931
2019-07-04 05:20:51 -07:00

59 lines
1.3 KiB
JavaScript

/**
* Copyright 2018-present Facebook.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* @format
* @flow strict-local
*/
import {FlipperPlugin, FlexColumn} from 'flipper';
type State = {||};
type Data = {||};
type PersistedState = {|
data: Array<Data>,
|};
export default class extends FlipperPlugin<State, {}, PersistedState> {
static title = 'Navigation';
static id = 'Navigation';
static icon = 'directions';
static keyboardActions = ['clear'];
static defaultPersistedState: PersistedState = {
data: [],
};
static persistedStateReducer = (
persistedState: PersistedState,
method: string,
data: Data,
): $Shape<PersistedState> => {
return {
...persistedState,
data: persistedState.data.concat([data]),
};
};
onKeyboardAction = (action: string) => {
if (action === 'clear') {
this.props.setPersistedState({data: []});
}
};
render() {
return (
<FlexColumn>
{this.props.persistedState.data.map((d, i) => (
<div key={i}>{JSON.stringify(d)}</div>
))}
</FlexColumn>
);
}
}
/* @scarf-info: do not remove, more info: https://fburl.com/scarf */
/* @scarf-generated: flipper-plugin index.js.template 0bfa32e5-fb15-4705-81f8-86260a1f3f8e */