npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-ionize

v1.5.0

Published

An experimental React renderer for Electron apps

Downloads

20

Readme

react-ionize

Electron applications consist of two types of process: a main process which manages the lifecycle of the application, and several renderer processes, which display webpages which comprise the application's GUI. It's fairly common to use React and ReactDOM to build a GUI in the renderer process.

react-ionize is a library which lets you use the same React component-based architechure to manage the lifecycle of your application in the Electron main process. It is essentially a replacement for ReactDOM- but instead of flushing component updates to a DOM, it flushes them out to Electron's API. Think React Native for Electron apps.

Caveat Developer

react-ionize is still an EXPERIMENTAL, PRE-ALPHA library, and is not yet suitable for for use in a production app! It's a custom renderer built on top of the React Fiber reconciliation API, which itself is still under active development. (Not to mention, I've got a whole crop of Electron features yet to add.)

Getting Started

* yarn add react-ionize 
* yarn add [email protected]

Take a look at Ionize Example App to get started.

Hello, world!

import React from 'react';
import Ionize from 'react-ionize';
import path from 'path';
import fs from 'fs';

const INDEX_HTML_PATH = path.resolve(__dirname, 'index.html');
const INDEX_HTML_SOURCE = `
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Hello, Electron!</title>
  </head>
  <body>
    <h1>Hello, Electron!</h1>
  </body>
</html>
`;

fs.writeFileSync(INDEX_HTML_PATH, INDEX_HTML_SOURCE);

Ionize.start(
  <app>
    <window show file={INDEX_HTML_PATH} />
  </app>
);

API

Ionize.start(element, [callback])

Starts up an Electron application under Ionize. (Note: this will wait on the 'ready' Electron event before starting to render any elements.)

Elements

Generally speaking, the presence of an Ionize element in your component tree indicates that you want it to be there, and that Ionize should ensure its presence when rendering. This can lead to slightly surprising behavior if you're unfamiliar with React- for instance, if you want a window to actually go away when you close it, you need to make sure that the corresponding <window/> element actually gets unmounted!

<app>

Attachment point for event handlers related to the global app. Not strictly necessary if you don't need to register any of these (since React Fiber now supports multiple children without a parent element).

Generally speaking, children of <app> are things related to the entire application: browser windows, dialogs, tray elements, and so forth. (Or at least, they will be once I get a chance to implement them.)

  • Event Handlers
    • onReady- Fired immediately when the component is mounted.

<window>

Represents an Electron BrowserWindow object.

  • file

    • The HTML file you want to render in the Chrome browser instance. (Note that Ionize looks up this file relative to the runtime location of your project!)
  • show

    • When this prop transitions from false -> true, Ionize displays the browser window. When it transitions from true -> false, Ionize hides (but does not close) the browser window. If this is true when the element is mounted, Ionize will immediately show the window.
  • showDevTools

    • If this is true when the element is mounted, Ionize will open the Chrome Developer Tools when opening the browser window.
  • Event Handlers

    • onReadyToShow
    • onClose
    • onClosed
    • onBlur
    • onFocus
    • onShow

<menu>

The <menu> element defines an Electron application menu.

TODO: When nested inside a <window> element, this should attach the menu to that window, specifically- and I'd like to have something like a element for right-clicks.

<submenu>

TBD

<item> and related

TBD

<dialog>

This is an odd duck. Since Electron's dialog API is more of a functional interface, I'm experimenting with an idea you could call a 'smart ref'- in other words, obtaining a ref to this element gives you an object which you can safely call show() on, which makes the appropriate function call based on the props you give <dialog>.

When mounted within a <window> element, calling show() on this will pop up a modal dialog in that window. Otherwise, it will pop up a modal dialog not linked to that window.