Skip to content

Latest commit

 

History

History
31 lines (24 loc) · 810 Bytes

custom-commands.md

File metadata and controls

31 lines (24 loc) · 810 Bytes

Setting up custom commands

Reactotron supports registering custom commands that can do anything you want when they are executed. When there are registered commands you can find them in the "Custom Commands" tab in reactotron.

Registering a command

// Way 1
Reactotron.onCustomCommand({
  command: "test2",
  handler: () => console.log("This is an example 2"),

  // Optional settings
  title: "A thing", // This shows on the button
  description: "The desc", // This shows below the button
})

// Way 2
Reactotron.onCustomCommand("test", () => console.log("This is an example"))

Unregistering a command

const selfRemoving = Reactotron.onCustomCommand({ // Save the result
  command: "remove",
  handler: () => {
    selfRemoving() // Calling it unregisters the command
  },
})