An open API service indexing awesome lists of open source software.

https://github.com/ericadamski/react-contextual-dialog

A simple set of dialog components that utilize react 16 context api
https://github.com/ericadamski/react-contextual-dialog

dialog dialog-component react react-16 react-context

Last synced: 27 days ago
JSON representation

A simple set of dialog components that utilize react 16 context api

Awesome Lists containing this project

README

          

# React Contextual Dialog

A simple set of dialog components that utilize React 16 context API

## Installation

`yarn add react-contextual-dialog` or `npm i react-contextual-dialog`

## Usage

[![Edit Example of react-contextual-dialog](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/n3omjooyzm)

Render a single `DialogContainer` heigher than you want to render the dialogs.

```javascript
import React from 'react';
import { render } from 'react-dom';
import ContextualDialog from 'react-contextual-dialog';

const Main = ({ children }) => (

{children}

);

render(, document.getElementById('app'));
```

You can now render a dialog anywhere in the `children` passed to ``

```javascript
import React, { Fragment } from 'react';
import { render } from 'react-dom';
import ContextualDialog from 'react-contextual-dialog';

const Dialog = ({ open, close, isOpen }) => (

{!isOpen && Open the dialog}
{isOpen && (


I am a dialog
Close Me

)}

);

const Popup = () => (



);

const Main = ({ children }) => (

{children}

);

render(


,
document.getElementById('app')
);
```