| title | slug | createdAt | language | preview |
|---|---|---|---|---|
React Hook prompting the user to "Add to homescreen" |
react-hook-prompting-the-user-to-add |
2018-11-29T20:35:02Z |
en |
Simple React Hook for showing the user a custom "Add to homescreen" prompt. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| let lsBus = {}; | |
| let ssBus = {}; | |
| /** | |
| * Redraw all components that have a hook to localStorage with the given key. | |
| * @param {string} key | |
| * @param {*} newValue | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let UserContext = React.createContext(); | |
| class App extends React.Component { | |
| state = { | |
| user: null, | |
| setUser: user => { | |
| this.setState({ user }); | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Install Node | |
| sudo apt-get install nodejs | |
| # Link command node | |
| sudo ln -s /usr/bin/nodejs /usr/bin/node | |
| # Install CURL | |
| sudo apt-get install curl |