adom-client

0.3.0 • Public • Published

adom-client

Adom client library

Adom Wrapper

Create an adom wrapper component.

import { AdomClient, AdomProvider, ThemeProvider } from 'adom-client';
const adomClient = new AdomClient(<ADOM_DOCKER_HOST>, <ADOM_DOCKER__PORT>);

const AdomWrapper = ({children}) => {
    return(
        <ThemeProvider>
            <AdomProvider client={adomClient}>
                {children}
            </AdomProvider>
        </ThemeProvider>
    )
}

Use adom context

Get context of AdomProvider

import { useAdom } from 'adom-client';

const AssistedContainer = ({children}) => {
    const adomContext = useAdom();
    return (
        <Assisted>
            <React.Fragment>
                {!!adomContext.initialize &&
                    <button onClick={init}>
                        Start call
                    </button>
                }
                <button onClick={hangUp}>
                    Hang up
                </button>
                {!!adomContext.peerID &&
                    <div>
                        PEER_ID => {adomContext.peerID}
                    </div>
                }
            </React.Fragment>
        </Assisted>
    )
}

Guide to create react library

https://hackernoon.com/creating-a-library-of-react-components-using-create-react-app-without-ejecting-d182df690c6b

Develop library locally

  • On root folder launch these commands: npm run build
    npm link
  • Use this linked library in other project: npm link adom-client

This project was bootstrapped with Create React App.

Readme

Keywords

none

Package Sidebar

Install

npm i adom-client

Weekly Downloads

53

Version

0.3.0

License

none

Unpacked Size

117 kB

Total Files

39

Last publish

Collaborators