0.1.10 • Published 22 days ago

react-hoc-modal v0.1.10

Weekly downloads
-
License
MIT
Repository
github
Last release
22 days ago

React component for easy create modals

install

npm i react-hoc-modal

// if you use typescript install types
npm i @types/react@{this you react version} @types/react-dom@{this you react version} -D

Examples

Mount modal provider

// index.js
import Modal from 'react-hoc-modal';
...
root.render(
  <React.StrictMode>
	<Modal.Provider SPA>
		<App />
	</Modal.Provider>
  </React.StrictMode>
);

Create modal component

// MyFirstModal.jsx
...
import Modal from 'react-hoc-modal';

const MyFirstModal = () => {

	return(<div>Hello, i am you first modal component</div>);
};

export default Modal.withModal(MyFirstModal,{
	title: 'Easy modal',
	theme: 'light'
});

Mount modal component

// App.jsx
...
import MyFirstModal from "./MyFirstModal";
...
const App = () => {
	...
	return(
		...
		<MyFirstModal/>
	);
}

Use modal component

<button onClick={MyFirstModal.show}>Show my first modal</button>

If you need update data without 'props', you can use the 'setState' method.

MyFirstModal.setState({testData: 'Hello'});

To get data use the 'state' property in the returned 'useModal' hook object.

const MyFirstModal = () => {
	const {state} = Modal.useModal();

	return(<div>{state?.testData}</div>);
};
0.1.10

22 days ago

0.1.8

3 months ago

0.1.7

3 months ago

0.1.9

3 months ago

0.1.6

3 months ago

0.1.5

3 months ago

0.1.4

4 months ago

0.1.0

7 months ago

0.1.2

6 months ago

0.1.1

7 months ago

0.0.9

7 months ago

0.0.8

7 months ago

0.0.5

7 months ago

0.1.3

6 months ago

0.0.4

7 months ago

0.0.7

7 months ago

0.0.6

7 months ago

0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago