Fix a crash when trying to remove a mock network call (#4403)
Summary: Crash when trying to remove a mock network call Issue: https://github.com/facebook/flipper/issues/3799 ## Changelog Read mock routes type error.Transform it from array to object. Pull Request resolved: https://github.com/facebook/flipper/pull/4403 Test Plan: Test passed on my Mac. Reviewed By: antonk52 Differential Revision: D42918910 Pulled By: passy fbshipit-source-id: 919bb6d2a2887aed46fb4a348f3f93e7abb765e5
This commit is contained in:
committed by
Facebook GitHub Bot
parent
035bcb6d0e
commit
42ac82bc8c
@@ -239,11 +239,15 @@ export function plugin(client: PluginClient<Events, Methods>) {
|
|||||||
function init() {
|
function init() {
|
||||||
supportsMocks(client.device)
|
supportsMocks(client.device)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
const newRoutes = JSON.parse(
|
const newRouteArray: [any] = JSON.parse(
|
||||||
localStorage.getItem(
|
localStorage.getItem(
|
||||||
LOCALSTORAGE_MOCK_ROUTE_LIST_KEY + client.appId,
|
LOCALSTORAGE_MOCK_ROUTE_LIST_KEY + client.appId,
|
||||||
) || '{}',
|
) || '[]',
|
||||||
);
|
);
|
||||||
|
const newRoutes: {[id: string]: any} = {};
|
||||||
|
newRouteArray.forEach((value, index) => {
|
||||||
|
newRoutes[index.toString()] = value;
|
||||||
|
});
|
||||||
batch(() => {
|
batch(() => {
|
||||||
routes.set(newRoutes);
|
routes.set(newRoutes);
|
||||||
isMockResponseSupported.set(result);
|
isMockResponseSupported.set(result);
|
||||||
|
|||||||
Reference in New Issue
Block a user