How to use Draft.js WYSWYG with Next.js and Strapi Backend, Create and View Article with Image Upload
Introduction In this post, we will use in Next.js with strapi. And, we will…
May 11, 2021
We have a page, for example a Form
. And, upon submission we would want user to be redirected to some other page and pass some state or props so that that page can show some message or so.
withRouter
import { withRouter } from 'next/router'
withRouter
export default withRouter(EditUser);
Now in your component’s props, you have a router object.
I have a user edit form, and upon submission. I want user to be redirected to /user/<id>
And, I want to show a message that edit has been successful.
this.props.router.push({
pathname: `/users/${user.id}`,
query: {success: true}
});
Here, I’m passing a query parameter to that page. So it will be:
/users/1234?success=true
In my component jsx file, I want to show a bootstrap alert.
return (
<SimpleLayout>
{props.router.query.success &&
<div className="alert alert-success alert-dismissible fade show" role="alert">
Success.
<Button type="button" className="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</Button>
</div>
}
...
...
</SimpleLayout>
}
)
Note the props.router.query.success
Introduction In this post, we will use in Next.js with strapi. And, we will…
Introduction In this post, we will do following: create a Next.js project…
Introduction I was trying to upload images to my backend using rest APIs. I was…
Introduction In this post we will see: How to prepare a docker image for your…
Introduction Strapi is a backend system provides basic crud operations with…
Introduction This post is in contuation of our previous post: How to use Draft…
Introduction This post has the complete code to send email through smtp server…
Introduction In a normal email sending code from python, I’m getting following…
Introduction In one of my app, I was using to talk to . I have used some event…
Introduction So you have a Django project, and want to run it using docker image…
Introduction It is very important to introduce few process so that your code and…
Introduction In this post, we will see a sample Jenkin Pipeline Groovy script…