Skip to content

night-js/react-night

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NPM version NPM downloads NPM license Travis Bundle size

night.js implementation for React

Demo

See plugin in action

How to Install

First, install the library in your project by npm:

$ npm install react-night

Or Yarn:

$ yarn add react-night

Getting Started

• Import NightProvider from library in your React app and wrap main component:

// index.js

import React from 'react';
import ReactDOM from 'react-dom';
import { NightProvider } from 'react-night';

import App from './App';

ReactDOM.render(
  <NightProvider config={{ /* night.js settings */ }}>
    <App />
  </NightProvider>,
  document.getElementById('root')
);

Example

• useNight hook:

// App.js

import React from 'react';
import { useNight } from 'react-night';

const App = () => {
  const { /* night.js params */ } = useNight();

  return (
    <h1>Hello Night!</h1>
  );
};

export default App;

• withNight HOC:

// App.js

import React from 'react';
import { withNight } from 'react-night';

const App = ({ /* night.js params */, ...props }) => {
  return (
    <h1>Hello Night!</h1>
  );
};

export default withNight(App);

License

This project is licensed under the MIT License © 2019-present Jakub Biesiada