Change prop of child component when s
I'm building my site with Gatsby and I'm trying to change the URL prop of the Plyr component when a user clicks on a lesson title. Right now the URL is set in the this.state
with data pulling from a GraphQL query to Contentful.
Here's a live version: https://brave-jepsen-d8ae28.netlify.com/courses/my-first-course
I created a handleChange function to set the state with the event.target.id
, but it's returning errors once I click on a lesson paragraph tag. Any idea what's going on? I tested that the event Id was being captured with a console.log(event.target.id)
, and it was, so I'm assuming it's something with rendering the component again once I attempt to set the state.
Any help is appreciated!
import React, { Component } from 'react'
import { Link, graphql } from 'gatsby'
import Layout from '../components/layout'
import Plyr from 'react-plyr'
import '../components/plyr.css'
// On click, set the value of that elements video url to video player url value
class CourseTemplate extends Component {
constructor(props) {
super(props);
this.state = {
url: props.data.contentfulCourse.featureVideo
};
this.handleChange = this.handleChange.bind(this);
};
handleChange(event) {
event.stopPropagation();
// console.log(event.target.id)
this.setState(prevState => ({
url: event.target.id
}));
}
render() {
const courseContent = this.props.data.contentfulCourse
return (
<Layout>
<Plyr key={this.state.url} type="vimeo" videoId={this.state.url}/>
<p>{this.state.url}</p>
<h1>{courseContent.title}</h1>
<p>{courseContent.shortDescription}</p>
<div>
{courseContent.teachers.map(teacher => (
<div key={teacher.id}>
<p>by <Link to={`/teachers/${teacher.id}`}>{teacher.name}</Link></p>
</div>
))}
</div>
<div>
{courseContent.lessons.map(lesson => (
<div key={lesson.lessonVideo}>
<p onClick={this.handleChange} id={lesson.lessonVideo}>{lesson.title}</p>
</div>
))}
</div>
</Layout>
)
}
};
export default CourseTemplate
export const query = graphql`
query CourseTemplate($id: String!) {
contentfulCourse(id: {eq: $id}) {
title
shortDescription
featureVideo
slug
teachers {
id
name
}
lessons {
id
title
lessonVideo
slug
}
}
}
`
Errors I'm receiving:
Warning: This synthetic event is reused for performance reasons. If you're seeing this, you're accessing the property 'target' on a released/nullified synthetic event. This is set to null. If you must keep the original synthetic event around, use event.persist().
TypeError: Cannot read property 'id' of null at ProxyComponent.eval
javascript reactjs graphql gatsby
add a comment |
I'm building my site with Gatsby and I'm trying to change the URL prop of the Plyr component when a user clicks on a lesson title. Right now the URL is set in the this.state
with data pulling from a GraphQL query to Contentful.
Here's a live version: https://brave-jepsen-d8ae28.netlify.com/courses/my-first-course
I created a handleChange function to set the state with the event.target.id
, but it's returning errors once I click on a lesson paragraph tag. Any idea what's going on? I tested that the event Id was being captured with a console.log(event.target.id)
, and it was, so I'm assuming it's something with rendering the component again once I attempt to set the state.
Any help is appreciated!
import React, { Component } from 'react'
import { Link, graphql } from 'gatsby'
import Layout from '../components/layout'
import Plyr from 'react-plyr'
import '../components/plyr.css'
// On click, set the value of that elements video url to video player url value
class CourseTemplate extends Component {
constructor(props) {
super(props);
this.state = {
url: props.data.contentfulCourse.featureVideo
};
this.handleChange = this.handleChange.bind(this);
};
handleChange(event) {
event.stopPropagation();
// console.log(event.target.id)
this.setState(prevState => ({
url: event.target.id
}));
}
render() {
const courseContent = this.props.data.contentfulCourse
return (
<Layout>
<Plyr key={this.state.url} type="vimeo" videoId={this.state.url}/>
<p>{this.state.url}</p>
<h1>{courseContent.title}</h1>
<p>{courseContent.shortDescription}</p>
<div>
{courseContent.teachers.map(teacher => (
<div key={teacher.id}>
<p>by <Link to={`/teachers/${teacher.id}`}>{teacher.name}</Link></p>
</div>
))}
</div>
<div>
{courseContent.lessons.map(lesson => (
<div key={lesson.lessonVideo}>
<p onClick={this.handleChange} id={lesson.lessonVideo}>{lesson.title}</p>
</div>
))}
</div>
</Layout>
)
}
};
export default CourseTemplate
export const query = graphql`
query CourseTemplate($id: String!) {
contentfulCourse(id: {eq: $id}) {
title
shortDescription
featureVideo
slug
teachers {
id
name
}
lessons {
id
title
lessonVideo
slug
}
}
}
`
Errors I'm receiving:
Warning: This synthetic event is reused for performance reasons. If you're seeing this, you're accessing the property 'target' on a released/nullified synthetic event. This is set to null. If you must keep the original synthetic event around, use event.persist().
TypeError: Cannot read property 'id' of null at ProxyComponent.eval
javascript reactjs graphql gatsby
1
"it's returning errors once I click" - can you show us the errors?
– Sergiu Paraschiv
Nov 12 at 15:14
I added a live example on brave-jepsen-d8ae28.netlify.com/courses/my-first-course, and I'm gettingTypeError: Cannot read property 'id' of null
On localhost I'm getting a longer errorsynthetic event is reused for performance reasons. If you're seeing this, you're accessing the property
target` on a released/nullified synthetic event. This is set to null. If you must keep the original synthetic event around, use event.persist()` plus theTypeError: Cannot read property 'id' of null
– Hunter Becton
Nov 12 at 15:22
1
Possible duplicate of Using event.target with React components - your issue is caused by Synthetic Events used by React.this.setState
is asynchronous so by the timeevent.target.id
is calledevent.target
can no longer be safely accessed.
– Sergiu Paraschiv
Nov 12 at 15:26
add a comment |
I'm building my site with Gatsby and I'm trying to change the URL prop of the Plyr component when a user clicks on a lesson title. Right now the URL is set in the this.state
with data pulling from a GraphQL query to Contentful.
Here's a live version: https://brave-jepsen-d8ae28.netlify.com/courses/my-first-course
I created a handleChange function to set the state with the event.target.id
, but it's returning errors once I click on a lesson paragraph tag. Any idea what's going on? I tested that the event Id was being captured with a console.log(event.target.id)
, and it was, so I'm assuming it's something with rendering the component again once I attempt to set the state.
Any help is appreciated!
import React, { Component } from 'react'
import { Link, graphql } from 'gatsby'
import Layout from '../components/layout'
import Plyr from 'react-plyr'
import '../components/plyr.css'
// On click, set the value of that elements video url to video player url value
class CourseTemplate extends Component {
constructor(props) {
super(props);
this.state = {
url: props.data.contentfulCourse.featureVideo
};
this.handleChange = this.handleChange.bind(this);
};
handleChange(event) {
event.stopPropagation();
// console.log(event.target.id)
this.setState(prevState => ({
url: event.target.id
}));
}
render() {
const courseContent = this.props.data.contentfulCourse
return (
<Layout>
<Plyr key={this.state.url} type="vimeo" videoId={this.state.url}/>
<p>{this.state.url}</p>
<h1>{courseContent.title}</h1>
<p>{courseContent.shortDescription}</p>
<div>
{courseContent.teachers.map(teacher => (
<div key={teacher.id}>
<p>by <Link to={`/teachers/${teacher.id}`}>{teacher.name}</Link></p>
</div>
))}
</div>
<div>
{courseContent.lessons.map(lesson => (
<div key={lesson.lessonVideo}>
<p onClick={this.handleChange} id={lesson.lessonVideo}>{lesson.title}</p>
</div>
))}
</div>
</Layout>
)
}
};
export default CourseTemplate
export const query = graphql`
query CourseTemplate($id: String!) {
contentfulCourse(id: {eq: $id}) {
title
shortDescription
featureVideo
slug
teachers {
id
name
}
lessons {
id
title
lessonVideo
slug
}
}
}
`
Errors I'm receiving:
Warning: This synthetic event is reused for performance reasons. If you're seeing this, you're accessing the property 'target' on a released/nullified synthetic event. This is set to null. If you must keep the original synthetic event around, use event.persist().
TypeError: Cannot read property 'id' of null at ProxyComponent.eval
javascript reactjs graphql gatsby
I'm building my site with Gatsby and I'm trying to change the URL prop of the Plyr component when a user clicks on a lesson title. Right now the URL is set in the this.state
with data pulling from a GraphQL query to Contentful.
Here's a live version: https://brave-jepsen-d8ae28.netlify.com/courses/my-first-course
I created a handleChange function to set the state with the event.target.id
, but it's returning errors once I click on a lesson paragraph tag. Any idea what's going on? I tested that the event Id was being captured with a console.log(event.target.id)
, and it was, so I'm assuming it's something with rendering the component again once I attempt to set the state.
Any help is appreciated!
import React, { Component } from 'react'
import { Link, graphql } from 'gatsby'
import Layout from '../components/layout'
import Plyr from 'react-plyr'
import '../components/plyr.css'
// On click, set the value of that elements video url to video player url value
class CourseTemplate extends Component {
constructor(props) {
super(props);
this.state = {
url: props.data.contentfulCourse.featureVideo
};
this.handleChange = this.handleChange.bind(this);
};
handleChange(event) {
event.stopPropagation();
// console.log(event.target.id)
this.setState(prevState => ({
url: event.target.id
}));
}
render() {
const courseContent = this.props.data.contentfulCourse
return (
<Layout>
<Plyr key={this.state.url} type="vimeo" videoId={this.state.url}/>
<p>{this.state.url}</p>
<h1>{courseContent.title}</h1>
<p>{courseContent.shortDescription}</p>
<div>
{courseContent.teachers.map(teacher => (
<div key={teacher.id}>
<p>by <Link to={`/teachers/${teacher.id}`}>{teacher.name}</Link></p>
</div>
))}
</div>
<div>
{courseContent.lessons.map(lesson => (
<div key={lesson.lessonVideo}>
<p onClick={this.handleChange} id={lesson.lessonVideo}>{lesson.title}</p>
</div>
))}
</div>
</Layout>
)
}
};
export default CourseTemplate
export const query = graphql`
query CourseTemplate($id: String!) {
contentfulCourse(id: {eq: $id}) {
title
shortDescription
featureVideo
slug
teachers {
id
name
}
lessons {
id
title
lessonVideo
slug
}
}
}
`
Errors I'm receiving:
Warning: This synthetic event is reused for performance reasons. If you're seeing this, you're accessing the property 'target' on a released/nullified synthetic event. This is set to null. If you must keep the original synthetic event around, use event.persist().
TypeError: Cannot read property 'id' of null at ProxyComponent.eval
javascript reactjs graphql gatsby
javascript reactjs graphql gatsby
edited Nov 12 at 15:29
asked Nov 12 at 15:02
Hunter Becton
185
185
1
"it's returning errors once I click" - can you show us the errors?
– Sergiu Paraschiv
Nov 12 at 15:14
I added a live example on brave-jepsen-d8ae28.netlify.com/courses/my-first-course, and I'm gettingTypeError: Cannot read property 'id' of null
On localhost I'm getting a longer errorsynthetic event is reused for performance reasons. If you're seeing this, you're accessing the property
target` on a released/nullified synthetic event. This is set to null. If you must keep the original synthetic event around, use event.persist()` plus theTypeError: Cannot read property 'id' of null
– Hunter Becton
Nov 12 at 15:22
1
Possible duplicate of Using event.target with React components - your issue is caused by Synthetic Events used by React.this.setState
is asynchronous so by the timeevent.target.id
is calledevent.target
can no longer be safely accessed.
– Sergiu Paraschiv
Nov 12 at 15:26
add a comment |
1
"it's returning errors once I click" - can you show us the errors?
– Sergiu Paraschiv
Nov 12 at 15:14
I added a live example on brave-jepsen-d8ae28.netlify.com/courses/my-first-course, and I'm gettingTypeError: Cannot read property 'id' of null
On localhost I'm getting a longer errorsynthetic event is reused for performance reasons. If you're seeing this, you're accessing the property
target` on a released/nullified synthetic event. This is set to null. If you must keep the original synthetic event around, use event.persist()` plus theTypeError: Cannot read property 'id' of null
– Hunter Becton
Nov 12 at 15:22
1
Possible duplicate of Using event.target with React components - your issue is caused by Synthetic Events used by React.this.setState
is asynchronous so by the timeevent.target.id
is calledevent.target
can no longer be safely accessed.
– Sergiu Paraschiv
Nov 12 at 15:26
1
1
"it's returning errors once I click" - can you show us the errors?
– Sergiu Paraschiv
Nov 12 at 15:14
"it's returning errors once I click" - can you show us the errors?
– Sergiu Paraschiv
Nov 12 at 15:14
I added a live example on brave-jepsen-d8ae28.netlify.com/courses/my-first-course, and I'm getting
TypeError: Cannot read property 'id' of null
On localhost I'm getting a longer error synthetic event is reused for performance reasons. If you're seeing this, you're accessing the property
target` on a released/nullified synthetic event. This is set to null. If you must keep the original synthetic event around, use event.persist()` plus the TypeError: Cannot read property 'id' of null
– Hunter Becton
Nov 12 at 15:22
I added a live example on brave-jepsen-d8ae28.netlify.com/courses/my-first-course, and I'm getting
TypeError: Cannot read property 'id' of null
On localhost I'm getting a longer error synthetic event is reused for performance reasons. If you're seeing this, you're accessing the property
target` on a released/nullified synthetic event. This is set to null. If you must keep the original synthetic event around, use event.persist()` plus the TypeError: Cannot read property 'id' of null
– Hunter Becton
Nov 12 at 15:22
1
1
Possible duplicate of Using event.target with React components - your issue is caused by Synthetic Events used by React.
this.setState
is asynchronous so by the time event.target.id
is called event.target
can no longer be safely accessed.– Sergiu Paraschiv
Nov 12 at 15:26
Possible duplicate of Using event.target with React components - your issue is caused by Synthetic Events used by React.
this.setState
is asynchronous so by the time event.target.id
is called event.target
can no longer be safely accessed.– Sergiu Paraschiv
Nov 12 at 15:26
add a comment |
1 Answer
1
active
oldest
votes
You don't need to use event
at all for this. You also don't need to pass a function to setState
since you're not doing anything with prevState
.
import React, { Component } from "react"
import { Link, graphql } from "gatsby"
import Layout from "../components/layout"
import Plyr from "react-plyr"
import "../components/plyr.css"
class CourseTemplate extends Component {
constructor(props) {
super(props)
this.state = {
url: props.data.course.featureVideo,
}
this.setVideoUrl = this.setVideoUrl.bind(this)
}
setVideoUrl(url) {
this.setState({ url })
}
render() {
const courseContent = this.props.data.course
return (
<Layout>
<Plyr type="vimeo" videoId={this.state.url} />
<div>
{courseContent.lessons.map(lesson => (
<div key={lesson.id}>
<p onClick={() => this.setVideoUrl(lesson.videoUrl)}>
{lesson.title}
</p>
</div>
))}
</div>
</Layout>
)
}
}
export default CourseTemplate
export const query = graphql`
query CourseTemplate($id: String!) {
course: contentfulCourse(id: { eq: $id }) {
title
shortDescription
featureVideo
slug
teachers {
id
name
}
lessons {
id
title
videoUrl: lessonVideo
slug
}
}
}
`
Thank you! This did the trick! I was getting issues with the Plyr component that I was using, so I switched to another react-player library and got it to work!
– Hunter Becton
Nov 12 at 19:43
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264866%2fchange-prop-of-child-component-when-s%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You don't need to use event
at all for this. You also don't need to pass a function to setState
since you're not doing anything with prevState
.
import React, { Component } from "react"
import { Link, graphql } from "gatsby"
import Layout from "../components/layout"
import Plyr from "react-plyr"
import "../components/plyr.css"
class CourseTemplate extends Component {
constructor(props) {
super(props)
this.state = {
url: props.data.course.featureVideo,
}
this.setVideoUrl = this.setVideoUrl.bind(this)
}
setVideoUrl(url) {
this.setState({ url })
}
render() {
const courseContent = this.props.data.course
return (
<Layout>
<Plyr type="vimeo" videoId={this.state.url} />
<div>
{courseContent.lessons.map(lesson => (
<div key={lesson.id}>
<p onClick={() => this.setVideoUrl(lesson.videoUrl)}>
{lesson.title}
</p>
</div>
))}
</div>
</Layout>
)
}
}
export default CourseTemplate
export const query = graphql`
query CourseTemplate($id: String!) {
course: contentfulCourse(id: { eq: $id }) {
title
shortDescription
featureVideo
slug
teachers {
id
name
}
lessons {
id
title
videoUrl: lessonVideo
slug
}
}
}
`
Thank you! This did the trick! I was getting issues with the Plyr component that I was using, so I switched to another react-player library and got it to work!
– Hunter Becton
Nov 12 at 19:43
add a comment |
You don't need to use event
at all for this. You also don't need to pass a function to setState
since you're not doing anything with prevState
.
import React, { Component } from "react"
import { Link, graphql } from "gatsby"
import Layout from "../components/layout"
import Plyr from "react-plyr"
import "../components/plyr.css"
class CourseTemplate extends Component {
constructor(props) {
super(props)
this.state = {
url: props.data.course.featureVideo,
}
this.setVideoUrl = this.setVideoUrl.bind(this)
}
setVideoUrl(url) {
this.setState({ url })
}
render() {
const courseContent = this.props.data.course
return (
<Layout>
<Plyr type="vimeo" videoId={this.state.url} />
<div>
{courseContent.lessons.map(lesson => (
<div key={lesson.id}>
<p onClick={() => this.setVideoUrl(lesson.videoUrl)}>
{lesson.title}
</p>
</div>
))}
</div>
</Layout>
)
}
}
export default CourseTemplate
export const query = graphql`
query CourseTemplate($id: String!) {
course: contentfulCourse(id: { eq: $id }) {
title
shortDescription
featureVideo
slug
teachers {
id
name
}
lessons {
id
title
videoUrl: lessonVideo
slug
}
}
}
`
Thank you! This did the trick! I was getting issues with the Plyr component that I was using, so I switched to another react-player library and got it to work!
– Hunter Becton
Nov 12 at 19:43
add a comment |
You don't need to use event
at all for this. You also don't need to pass a function to setState
since you're not doing anything with prevState
.
import React, { Component } from "react"
import { Link, graphql } from "gatsby"
import Layout from "../components/layout"
import Plyr from "react-plyr"
import "../components/plyr.css"
class CourseTemplate extends Component {
constructor(props) {
super(props)
this.state = {
url: props.data.course.featureVideo,
}
this.setVideoUrl = this.setVideoUrl.bind(this)
}
setVideoUrl(url) {
this.setState({ url })
}
render() {
const courseContent = this.props.data.course
return (
<Layout>
<Plyr type="vimeo" videoId={this.state.url} />
<div>
{courseContent.lessons.map(lesson => (
<div key={lesson.id}>
<p onClick={() => this.setVideoUrl(lesson.videoUrl)}>
{lesson.title}
</p>
</div>
))}
</div>
</Layout>
)
}
}
export default CourseTemplate
export const query = graphql`
query CourseTemplate($id: String!) {
course: contentfulCourse(id: { eq: $id }) {
title
shortDescription
featureVideo
slug
teachers {
id
name
}
lessons {
id
title
videoUrl: lessonVideo
slug
}
}
}
`
You don't need to use event
at all for this. You also don't need to pass a function to setState
since you're not doing anything with prevState
.
import React, { Component } from "react"
import { Link, graphql } from "gatsby"
import Layout from "../components/layout"
import Plyr from "react-plyr"
import "../components/plyr.css"
class CourseTemplate extends Component {
constructor(props) {
super(props)
this.state = {
url: props.data.course.featureVideo,
}
this.setVideoUrl = this.setVideoUrl.bind(this)
}
setVideoUrl(url) {
this.setState({ url })
}
render() {
const courseContent = this.props.data.course
return (
<Layout>
<Plyr type="vimeo" videoId={this.state.url} />
<div>
{courseContent.lessons.map(lesson => (
<div key={lesson.id}>
<p onClick={() => this.setVideoUrl(lesson.videoUrl)}>
{lesson.title}
</p>
</div>
))}
</div>
</Layout>
)
}
}
export default CourseTemplate
export const query = graphql`
query CourseTemplate($id: String!) {
course: contentfulCourse(id: { eq: $id }) {
title
shortDescription
featureVideo
slug
teachers {
id
name
}
lessons {
id
title
videoUrl: lessonVideo
slug
}
}
}
`
answered Nov 12 at 18:25
coreyward
49.3k1595124
49.3k1595124
Thank you! This did the trick! I was getting issues with the Plyr component that I was using, so I switched to another react-player library and got it to work!
– Hunter Becton
Nov 12 at 19:43
add a comment |
Thank you! This did the trick! I was getting issues with the Plyr component that I was using, so I switched to another react-player library and got it to work!
– Hunter Becton
Nov 12 at 19:43
Thank you! This did the trick! I was getting issues with the Plyr component that I was using, so I switched to another react-player library and got it to work!
– Hunter Becton
Nov 12 at 19:43
Thank you! This did the trick! I was getting issues with the Plyr component that I was using, so I switched to another react-player library and got it to work!
– Hunter Becton
Nov 12 at 19:43
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264866%2fchange-prop-of-child-component-when-s%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
"it's returning errors once I click" - can you show us the errors?
– Sergiu Paraschiv
Nov 12 at 15:14
I added a live example on brave-jepsen-d8ae28.netlify.com/courses/my-first-course, and I'm getting
TypeError: Cannot read property 'id' of null
On localhost I'm getting a longer errorsynthetic event is reused for performance reasons. If you're seeing this, you're accessing the property
target` on a released/nullified synthetic event. This is set to null. If you must keep the original synthetic event around, use event.persist()` plus theTypeError: Cannot read property 'id' of null
– Hunter Becton
Nov 12 at 15:22
1
Possible duplicate of Using event.target with React components - your issue is caused by Synthetic Events used by React.
this.setState
is asynchronous so by the timeevent.target.id
is calledevent.target
can no longer be safely accessed.– Sergiu Paraschiv
Nov 12 at 15:26