Comments (3)
I ran into the same issue, the issue lies in the new React...where .params are no longer supported in class functions. I saw a comment on youtube that got me mostly there. My solution (does not include UseEffect() yet) was to convert Room() to a functional Component and implement useParams() instead of the original "props.match.params.roomCode".
import React, { Component, useState } from 'react';
import { useParams } from 'react-router-dom';
function Room() {
const { roomCode } = useParams()
const initialState = {
votesToSkip: 2,
guestCanPause: false,
isHost: false
}
const [roomData, setRoomData] = useState(initialState)
return(
<div>
<h3>{roomCode}</h3>
<p>Votes: {roomData.votesToSkip}</p>
<p>Guest Can Pause: {roomData.guestCanPause.toString()}</p>
<p>Host: {roomData.isHost.toString()}</p>
</div>
);
}
export default Room;
from music-controller-web-app-tutorial.
Has this issue been fixed?
from music-controller-web-app-tutorial.
I managed to find a solution where I wrapped the Room class with a component to pass additional props to it.
function withParams(Component) {
return (props) => (
<Component {...props} params={useParams()} navigate={useNavigate()} />
);
}
and then at the bottom of the code:
export default withParams(Room);
This seemed to work well for me.
from music-controller-web-app-tutorial.
Related Issues (20)
- Tutorial 13 - unsupported type for timedelta seconds component: NoneType HOT 4
- HTTP 405 Method Not Allowed HOT 1
- Song not playing on other devices in the same room HOT 2
- Wrong APIView leading to no POST form in UI
- node run dev MODULE_NOT_FOUND error on Tutorial 3 HOT 3
- npm run dev HOT 1
- 204 error while running execute_spotify_api_request
- Nothing shown on the screen - tutorial 4 HOT 5
- Tutorial 3. Where should rest_framework be located? HOT 1
- T4, routing pages HOT 1
- wont run
- song does not play on guest device
- Type Error in Tutorial 5
- Spotify API Tokens
- Docker + TypeScript
- class Room has no objects member HOT 4
- ...
- app.js import homepage.html HOT 1
- No redirect after Spotify login HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from music-controller-web-app-tutorial.