Closed mahabbatmh closed 4 years ago
I have issue with react-snap configuration. my index.js: `import React from 'react'; import './index.css'; import App from './App'; import { AComponent, BComponent } from "./App"; import { BrowserRouter, Route ,Switch } from 'react-router-dom'; import { hydrate, render } from "react-dom"; const Routing = () => (
index.js
);
const rootElement = document.getElementById("root"); if (rootElement.hasChildNodes()) { hydrate(, rootElement); } else { render(, rootElement); } `
`import React from 'react'; import logo from './logo.svg'; import './App.css'; import { Link } from "react-router-dom";
export function AComponent(){ return (
) }
export function BComponent(){ return (
function App() { return (
Edit src/App.js and save to reload.
src/App.js
); }`
export default App;
{ "name": "prerender", "version": "0.1.0", "private": true, "dependencies": { "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.3.2", "@testing-library/user-event": "^7.1.2", "react": "^16.12.0", "react-dom": "^16.12.0", "react-router-dom": "^5.1.2", "react-scripts": "3.3.0" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject", "postbuild": "react-snap" }, "eslintConfig": { "extends": "react-app" }, "browserslist": { "production": [ ">0.2%", "not dead", "not op_mini all" ], "development": [ "last 1 chrome version", "last 1 firefox version", "last 1 safari version" ] }, "devDependencies": { "react-snap": "^1.23.0" } }
When I reloaded/a path, I get HTML of main page.
/a
@mahabbatmh I'm having the same issue. Were you able to solve the problem?
I have issue with react-snap configuration. my
index.js
: `import React from 'react'; import './index.css'; import App from './App'; import { AComponent, BComponent } from "./App"; import { BrowserRouter, Route ,Switch } from 'react-router-dom'; import { hydrate, render } from "react-dom"; const Routing = () => ();
const rootElement = document.getElementById("root"); if (rootElement.hasChildNodes()) { hydrate( , rootElement);
} else {
render( , rootElement);
}
`
App.js
`import React from 'react'; import logo from './logo.svg'; import './App.css'; import { Link } from "react-router-dom";
export function AComponent(){ return (
) }
export function BComponent(){ return (
) }
function App() { return (
Edit
A component B componentsrc/App.js
and save to reload.); }`
export default App;
package.json:
{ "name": "prerender", "version": "0.1.0", "private": true, "dependencies": { "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.3.2", "@testing-library/user-event": "^7.1.2", "react": "^16.12.0", "react-dom": "^16.12.0", "react-router-dom": "^5.1.2", "react-scripts": "3.3.0" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject", "postbuild": "react-snap" }, "eslintConfig": { "extends": "react-app" }, "browserslist": { "production": [ ">0.2%", "not dead", "not op_mini all" ], "development": [ "last 1 chrome version", "last 1 firefox version", "last 1 safari version" ] }, "devDependencies": { "react-snap": "^1.23.0" } }
When I reloaded
/a
path, I get HTML of main page.