night.js implementation for React
First, install the library in your project by npm:
$ npm install react-night
Or Yarn:
$ yarn add react-night
• 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')
);
• 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);
This project is licensed under the MIT License © 2019-present Jakub Biesiada