MCPcopy
hub / github.com/preactjs/preact / constructor

Method constructor

compat/test/browser/context.test.jsx:51–60  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

49 */
50 class Router extends Component {
51 constructor(props) {
52 super(props);
53 this.state = { location: route1 };
54 toggleLocation = () => {
55 const oldLocation = this.state.location;
56 const newLocation = oldLocation === route1 ? route2 : route1;
57 // console.log('Toggling location', oldLocation, '->', newLocation);
58 this.setState({ location: newLocation });
59 };
60 }
61
62 render() {
63 // console.log('Rendering Router', { location: this.state.location });

Callers

nothing calls this directly

Calls 1

setStateMethod · 0.80

Tested by

no test coverage detected