React Class Component example?
See original GitHub issueGreat library! I actually prefer having all the pages is JSON-ish format, plus you get the benefits of react-loadable built in which is perfect.
I was trying this out and wanted to see if there’s an example of a route which uses a react class component instead of a function.
So instead of
// pages/reference.js
import * as React from 'react'
export default function Reference() {
return (
<div>
<h2>Reference</h2>
</div>
)
}
What would be the createPage
syntax for this:
import React from 'react'
export default class Reference extends React.Component {
render() {
return <h2>Smart Page!</h2>;
}
}
Thank you!
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
React Class Components - W3Schools
When creating a React component, the component's name must start with an upper case letter. The component has to include the extends React.Component...
Read more >Components and Props - React
Components let you split the UI into independent, reusable pieces, and think about each piece in isolation. This page provides an introduction to...
Read more >ReactJS Class Based Components - GeeksforGeeks
React class based components are the bread and butter of most modern web apps built in ReactJS. These components are simple classes (made...
Read more >The Best React Examples - freeCodeCamp
React Component Example ... Components are reusable in React.js. You can inject value into props as given below: function Welcome(props) { return ...
Read more >Component State: React State Cheatsheet - Codecademy
React class components store their state as a JavaScript object. This object is initialized in the component's constructor() . In the example, the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Have just merged this change, so that
content
properties that are functions will now be treated as function components, and have aroute
property passed in.This will be part of 0.11, which should be released soon after React 16.8 is (with hooks support).
I’ve just made a change to allow this and released it with react-navi 0.9. You can see a demo here:
https://frontarm.com/demoboard/?id=ec703f64-fa4f-4110-9323-8c46de76186f
Previously, if
<NavRoute />
saw a function inroute.content
, it would call it to get the rendered element. I’ve kept this behavior for plain functions, but now it’ll check to see if the content is a class component and create an element if it is, passing through theRoute
object as props.