Skip to content

Instantly share code, notes, and snippets.

@aleclarson
Last active March 10, 2019 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aleclarson/1eb38f8a1560a910692b624325d38767 to your computer and use it in GitHub Desktop.
Save aleclarson/1eb38f8a1560a910692b624325d38767 to your computer and use it in GitHub Desktop.
<NSWindow />

This document explores the potential API for NSWindow management in react-native-macos.

<Window> component

<Window>
  {/* content goes here */}
</Window>

Nesting <Window> components is forbidden.

Props

  • style: StyleProp<ViewStyle>
  • title: string
  • titleBarStyle: "default" | "overlay" | "none"
  • closable: boolean
  • minimizable: boolean
  • resizable: boolean
  • borderless: boolean
  • alwaysOnTop: boolean
  • canBecomeKey: boolean
  • canBecomeMain: boolean
  • onBecomeKey: () => void
  • onResignKey: () => void
  • onBecomeMain: () => void
  • onResignMain: () => void
  • onLayout: ({ nativeEvent: { x: number, y: number, width: number, height: number } }) => void
  • onMinimize: () => void
  • onMaximize: () => void

 

useWindow() hook

The useWindow hook returns the <Window> instance that the caller is contained by.

const window = useWindow()

Window.prototype

  • focus(): void
  • close(): void
  • minimize(): void
  • maximize(): void

 

Window.open()

The Window.open() static method lets you open a window programatically.

Window.open(() => <Window />)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment