All Projects → anubhavsrivastava → React For Electron Only

anubhavsrivastava / React For Electron Only

Licence: mit
React component for rendering component for Electron based clients only

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React For Electron Only

Android Messages Desktop
Android Messages as a Cross-platform Desktop App
Stars: ✭ 969 (+2053.33%)
Mutual labels:  desktop
Download Manager
Download Manager with features like in IDM
Stars: ✭ 36 (-20%)
Mutual labels:  desktop
Mlde.d.moonlightde
Modular and Qt5 light new behavior desktop environment
Stars: ✭ 40 (-11.11%)
Mutual labels:  desktop
React Animated Weather
Animated weather component for React inspired by Skycons http://darkskyapp.github.io/skycons/ ☀️
Stars: ✭ 34 (-24.44%)
Mutual labels:  react-component
React Notifications Component
Delightful and highly customisable React Component to notify your users
Stars: ✭ 978 (+2073.33%)
Mutual labels:  react-component
Old Slack Emojis
Bring back old emojis to new Slack!
Stars: ✭ 39 (-13.33%)
Mutual labels:  desktop
React Splide
The Splide component for React.
Stars: ✭ 32 (-28.89%)
Mutual labels:  react-component
Desktopeditors
An office suite that combines text, spreadsheet and presentation editors allowing to create, view and edit local documents
Stars: ✭ 1,008 (+2140%)
Mutual labels:  desktop
Spicy Datatable
React.js datatables without jQuery. Smart react datatable that includes search, pagination and localization.
Stars: ✭ 36 (-20%)
Mutual labels:  react-component
Essentialnowplaying
A now playing tool intended to be used with OBS.
Stars: ✭ 40 (-11.11%)
Mutual labels:  desktop
Revery
⚡ Native, high-performance, cross-platform desktop apps - built with Reason!
Stars: ✭ 7,812 (+17260%)
Mutual labels:  desktop
React Markdown Preview
React component preview markdown text in web browser. The minimal amount of CSS to replicate the GitHub Markdown style.
Stars: ✭ 34 (-24.44%)
Mutual labels:  react-component
Reimgix
🌇 Get all the benefits of Imgix using React. Supports LQIP.
Stars: ✭ 39 (-13.33%)
Mutual labels:  react-component
Mywintiles
Tiling window manager for Windows 10, Built on top of explorer shell
Stars: ✭ 34 (-24.44%)
Mutual labels:  desktop
React Nouislider
React wrapper on NoUiSlider
Stars: ✭ 41 (-8.89%)
Mutual labels:  react-component
Electra
A desktop application for test account managment
Stars: ✭ 32 (-28.89%)
Mutual labels:  desktop
Uwp Fulltrust
Stars: ✭ 37 (-17.78%)
Mutual labels:  desktop
Atomos
JS-based Linux desktop environment.
Stars: ✭ 42 (-6.67%)
Mutual labels:  desktop
Shadertoy Rs
A desktop client for Shadertoy written in Rust
Stars: ✭ 41 (-8.89%)
Mutual labels:  desktop
Paperview
A high performance X11 animated wallpaper setter
Stars: ✭ 999 (+2120%)
Mutual labels:  desktop

react-for-electron-only

build status Coverage Status PRs Welcome GitHub issues

NPM

React component for rendering component for Electron based clients only. If you’re serving up the same code to a Web client and an Electron-based desktop client, this could help you split them apart where-ever necessary. It can be used for detection of Electron (ref: isElectron function). <ForElectronOnly> would render children in case when react application runs in Electron Desktop client, else would render nothing(null) .

Use Cases

Trivial Case

Considering any isomorphic app which is distributed on ElectronJS and also over Web with same react codebase, say for eg. slack (which renders same UI on electron desktop client and web), there are use cases when you want to render particular DOM node/components on Electron Only and not on browser or vice versa.

Exclusive Functionality

There are set of APIs from electron that would give native UI feel eg, dialog module. For instance, one may have folder/file path as input text on browser while on electron one may use dialog.showOpenDialog functionality via a button. Use of such APIs also eliminate some validation errors.

Install

$ npm install electron-only --save

or

yarn add electron-only

Example

  1. <ForElectronOnly>

    import ForElectronOnly from 'electron-only';
    
    ...
    render(){
        return (
            <ForElectronOnly>
                <div className="electron-ui">
                    This will only get rendered on Electron
                </div>
            </ForElectronOnly>
        )
    }
    ...
    

    This will render div.electron-ui on electron and nothing on normal browsers.

  2. <ForElectronOnly> with fallbackComponent option

    import ForElectronOnly from 'electron-only';
    
    ...
    render(){
        return (
            <ForElectronOnly
            fallbackComponent={<div className="browser-ui"> This will only get rendered in Browser </div>}>
                <div className="electron-ui">
                    This will only get rendered on Electron
                </div>
            </ForElectronOnly>
        )
    }
    ...
    

    This will render div.electron-ui on electron and div.browser-ui on browser.

  3. ForNonElectronOnly (supports fallbackComponent prop)

    import {ForNonElectronOnly} from 'electron-only';
    
    ...
    render(){
        return (
            <ForNonElectronOnly
            fallbackComponent={<div className="electron-ui"> This will only get rendered in Electron </div>}>
                <div className="browser-ui">
                    This will only get rendered on Browser
                </div>
            </ForNonElectronOnly>
        )
    }
    ...
    

    ForNonElectronOnly is exactly opposite of ForElectronOnly, ie, it will render div.electron-ui on electron and div.browser-ui on browser.

APIs

ForElectronOnly Component

Import mechanism

import ForElectronOnly from 'electron-only'

Properties

prop type description default value
children (default) node Component to be render for electron null
fallbackComponent node Component/Node to be rendered for browser null

ForNonElectronOnly Component

Import mechanism

import {ForNonElectronOnly} from 'electron-only'

Properties

prop type description default value
children (default) node Component to be render for browser null
fallbackComponent node Component/Node to be rendered for electron null

isElectron function

Import mechanism

import {isElectron} from 'electron-only'
//or import ElectronOnly from 'electron-only';
// and then ElectronOnly.isElectron function can be used

Return values

value description comment
true if code is executed on Electron
false if code is not executed on Electron implies both browser and server execution

Contribution

Suggestions and PRs are welcome!

Please create issue or open PR request for contribution.


License

Open Source Love

refer LICENSE file in this repository.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].