2

So, I've tried all this but none of them work.

<Route name="create-course" handler={CreateCourse} path="/course-builder/create-course/{:id}" />
<Route name="create-course" handler={CreateCourse} path="/course-builder/create-course/[:id]" />
<Route name="create-course" handler={CreateCourse} path="/course-builder/create-course{/id}" />

variants of the same error:

Error: Invariant Violation: Missing "id" parameter for path "/course-builder/create-course/{:id}"

/{:id?} one doesn't throw an error but URL becomes

/course-builder/create-course/%7B%7D

Help please!

0

2 Answers 2

2

After param :id add ?, like so

<Route name="create-course" handler={CreateCourse} path="/course-builder/create-course/:id?" />
Sign up to request clarification or add additional context in comments.

Comments

0

In case someone else stumbles upon this question - as of React-Router v1.0.0 the correct syntax is:

<Route name="create-course" handler={CreateCourse} path="/course-builder/create-course(/:id)" />

Documentation here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.