apply suggestions
continuous-integration/drone/push Build is passing Details

pull/3/head
maxime.batista 1 year ago
parent e7f5cc72c5
commit 7df33f32b5

@ -144,7 +144,7 @@ function _asset(string $assetURI): string {
Conventions regarding our react views __must be respected in order to be renderable__.
### The `render(any)` function
__any react view file__ should __export__ a function with signature `render(arguments: any)`, which responsibility is to render the view.
Any React view component needs to be default exported in order to be imported and used from PHP. Those components will receive as props the arguments that the PHP server has transmitted.
The `arguments` parameter is used to pass data to the react component.
If you take a look at the `front/views/SampleForm.tsx` view, here's the definition of its render function :

@ -4,7 +4,6 @@
"App\\": "src/"
}
},
"include-path": ["src"],
"require": {
"altorouter/altorouter": "1.2.0",
"ext-json": "*"

@ -12,7 +12,7 @@
"@types/react-dom": "^18.2.14",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^4.9.5",
"typescript": "^5.2.2",
"vite": "^4.5.0",
"web-vitals": "^2.1.4"
},
@ -27,18 +27,6 @@
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@vitejs/plugin-react": "^4.1.0"
}

@ -34,8 +34,8 @@ $match = $router->match();
if ($match == null) {
// TODO redirect to a 404 not found page instead (issue #1)
echo "page non trouvée";
header('HTTP/1.1 404 Not Found');
http_response_code(404);
echo "Page non trouvée";
exit(1);
}

@ -2,7 +2,7 @@
namespace App\Controller;
require_once "react-display.php";
require_once __DIR__ . "/../react-display.php";
class SampleFormController {
public function displayForm() {

@ -10,11 +10,11 @@
RefreshRuntime.injectIntoGlobalHook(window)
window.\$RefreshReg$ = () => {}
window.\$RefreshSig$ = () => (type) => type
window.__vite_plugin_react_preamble_installed__ = true
";
}
?>
window.__vite_plugin_react_preamble_installed__ = true
</script>
<link rel="icon" href="<?= asset("assets/favicon.ico") ?>">
@ -24,7 +24,9 @@
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body id="root">
<body>
<div id="root"></div>
<!--
here's the magic.

Loading…
Cancel
Save