This repository was archived by the owner on Oct 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
JS Utilities
George Treviranus edited this page Jun 14, 2018
·
4 revisions
Using Undernet's JavaScript components is very straightforward. There are two options: import the library into a javascript file, or link it just before the end of your <body> tag. Either way, Undernet will be attached to the window object for you to access.
Turn on event listeners on components manually. start() is a method on the Undernet object.
// vanilla JS
var startMonolith = Undernet.start()
document.addEventListener("DOMContentLoaded", startMonolith)// React
import React from 'react'
import Undernet from 'undernet'
export default someComponent extends React.Component {
componentDidMount() {
Undernet.start()
}
}Turn off event listeners on components manually. stop() is a method on the Undernet object.
// vanilla JS
Undernet.stop()// React
import Undernet from 'undernet'
export default someComponent extends React.Component {
componentWillUnmount() {
Undernet.stop()
}
}If you prefer not to use all of Undernet's components at once like above, you can instead access similarly named methods on a specific component.
// vanilla JS
var startAccordions = Undernet.Accordions.start()
document.addEventListener("DOMContentLoaded", startAccordions)// React
import React from 'react'
import Undernet from 'undernet'
export default someComponent extends React.Component {
componentDidMount() {
Undernet.Accordions.start()
}
}