Skip to content

Instantly share code, notes, and snippets.

@BenBroide
Created May 28, 2020 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenBroide/e860dc82240c3f076ba4b988e0968af2 to your computer and use it in GitHub Desktop.
Save BenBroide/e860dc82240c3f076ba4b988e0968af2 to your computer and use it in GitHub Desktop.
CRA + WordPress. wp admin. Function plugin
import React from 'react'
import ReactDOM from 'react-dom'
import './index.css'
import App from './App'
import * as serviceWorker from './serviceWorker'
const reactAppData = window.rpReactPlugin || {}
const { appSelector } = reactAppData
const appAnchorElement = document.querySelector(appSelector)
if (appAnchorElement) {
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
appAnchorElement
)
}
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment