How to add image to bootstrap card as a preview in react? - reactjs

I am trying to create a bootstrap form and i want to show as a preview in bootstrap card what it will look like
Here is my code for form
<div className="container">
<div className="row">
<div className="col p-5">
<div className="card" style={{ width: "18rem" }}>
<img data-src={img} className="card-img-top" alt="any image"/>
<div className="card-body">
<h5 className="card-title">{title}</h5>
<p className="card-text">{place}</p>
<p className="card-text">{year}</p>
<a href="#" className="btn btn-primary">
Go somewhere
</a>
</div>
</div>
</div>
<div className="col p-5">
<form type="form">
<div className="form-group">
<label>Title</label>
<input
name="title"
type="text"
className="form-control mt-2"
placeholder="Enter name of car"
value={title}
onChange={(e) => setTitle(e.target.value)}
/>
</div>
<div className="form-group">
<label>Place</label>
<input
name="place"
type="text"
className="form-control mt-2"
placeholder="Enter city name"
value={place}
onChange={(e) => setPlace(e.target.value)}
/>
</div>
<div className="form-group">
<label>Year</label>
<input
name="year"
type="number"
className="form-control mt-2"
placeholder="Enter mfg year"
value={year}
onChange={(e) => setYear(e.target.value)}
/>
</div>
<div className="form-group">
<input
className=" mt-2"
type="file"
name="file"
value={img}
onChange={changeHandler}
/>
</div>
{error && <div>{error}</div>}
{file && <div>{file.name}</div>}
<button
onClick={uploadFile}
type="submit"
className="btn btn-primary mt-2"
>
Submit
</button>
</form>
</div>
</div>
</div>
I can preview title as given in input field by passing as value parameter but i don't know how to do it with image. Also i am storing value of title,place etc in variable do i need to do the same for image too?

Related

the recent form submission is active and when i tried to send data from live to netlify then recent from submussion is empty

here is the code of component and i screenshot i have accached the code of index.html which located in public file of react. anyone please help me!! please follow the screenshot. (language used - reactJS, css - tailwind)
<form
name="contact-form"
netlify
netlify-honeypot="bot-field"
hidden
className="flex flex-wrap -m-2"
>
<input type="hidden" name="form-name" value="contact-form" />
<div className="p-2 w-1/2">
<div className="relative">
<input
type="text"
id="name"
name="name"
required
/>
</div>
</div>
<div className="p-2 w-1/2">
<div className="relative">
<input
type="email"
id="email"
name="email"
required
/>
</div>
</div>
<div className="p-2 w-1/2">
<div className="relative">
<input
type="text"
id="trip"
name="trip"
required
/>
</div>
</div>
<div className="p-2 w-1/2">
<div className="relative">
<input
type="number"
id="pax"
name="pax"
required
/>
</div>
</div>
<div className="p-2 w-full">
<BlueButton type="submit">Enquiry Now</BlueButton>
</div>
</form>
public html code

how can i edit the value of add multiple dynamic form in react class?

I'm working on dynamic react form. I want to update dynamic form data. I have populate and get the data from backend successfully but when I enter in input field for change some data then I'm not able to change it. I am adding here my form image. Please check and tell me how can I can fix it.
import React from "react"
const VarientDetailEdit = (props) => {
return (
props.varientDetails.map((val, idx) => {
let sort=`sort-${idx}`, sku=`sku-${idx}`, waightunitno=`waightunitno-${idx}`, unit=`unit-${idx}`, mrp=`mrp-${idx}`, discount=`discount-${idx}`, price=`price-${idx}`, stock=`stock-${idx}`, minstock=`minstock-${idx}`, outofstock=`outofstock-${idx}`
return (
<div>
<div style={{float:"right"}}>
{
idx ?
<button style={{paddingLeft:"10px"}} className="btn btn-danger" onClick={(() => props.delete(val))} ><i className="fa fa-minus" aria-hidden="true"></i></button> : null
}
</div>
<div><br></br><br></br>
<div key={val.index} className='row'>
<div class="form-group col-sm-4">
<label>Sort:</label>
<input type="text" value={val.sort} name="sort" data-id={idx} id={sort} className="form-control " />
</div>
<div class="form-group col-sm-4">
<label>SKU</label>
<input type="text" value={val.sku} name="sku" data-id={idx} id={sku} className="form-control " />
</div>
<div class="form-group col-sm-4">
<label>Weight/Quantity</label>
<input type="text" value={val.waightunitno} name="waightunitno" id={waightunitno} data-id={idx} className="form-control " />
</div>
</div>
<div className='row'>
<div class="form-group col-sm-4">
<label>Unit</label>
<input type="text" value={val.unit} name="unit" id={unit} data-id={idx} className="form-control " />
</div>
<div class="form-group col-sm-4">
<label>MRP <em style={{color:"tomato"}}>*</em></label>
<input type="text" value={val.mrp} name="mrp" id={mrp} data-id={idx} className="form-control " />
</div>
<div class="form-group col-sm-4">
<label>Discount(%) <em style={{color:"tomato"}}>*</em></label>
<input type="text" value={val.discount} name="discount" id={discount} data-id={idx} className="form-control " />
</div>
</div>
<div className='row'>
<div class="form-group col-sm-4">
<label>Price <em style={{color:"tomato"}}>*</em></label>
<input type="text" value={val.price} name="price" id={price} data-id={idx} className="form-control " />
</div>
<div class="form-group col-sm-4">
<label>Stock <em style={{color:"tomato"}}>*</em></label>
<input type="text" value={val.stock} name="stock" id={stock} data-id={idx} className="form-control " />
</div>
<div class="form-group col-sm-4">
<label>Min Stock Alert <em style={{color:"tomato"}}>*</em></label>
<input type="text" value={val.minstock} name="minstock" id={minstock} data-id={idx} className="form-control " />
</div>
<div className='col-sm-4'>
<div className="form-group">
<label className="form-label">Variant Out of Stock Status <em style={{color:"tomato"}}>*</em></label>
<select name="outofstock" value={val.outofstock} id={outofstock} data-id={idx} className="form-control" >
<option value="pending">Pending</option>
<option value="In Progress">In progress</option>
<option value="Completed">Completed</option>
<option value="Hold">Hold</option>
</select>
</div>
</div>
<hr className="my-4"></hr>
</div>
</div>
</div>
)
})
)
}
export default VarientDetailEdit
Parent component
handleChange = (e) => {
if (["sort", "sku", "waightunitno", "unit", "mrp", "discount", "price", "stock", "minstock", "outofstock"].includes(e.target.name)) {
let varientDetails = [...this.state.varientDetails]
varientDetails[e.target.dataset.id][e.target.name] = e.target.value;
} else if (["isTex"].includes(e.target.name)) {
this.setState({ [e.target.name]: e.target.value })
console.log(e)
// }else if (["files[]"].includes(e.target.name)) {
// this.setState({ files:e.target.files });
}
else {
this.setState({ [e.target.name]: e.target.value })
}
}
addNewRow = () => {
this.setState((prevState) => ({
varientDetails: [...prevState.varientDetails, { index: Math.random(), sort:5,
sku: "",
waightunitno: "",
unit:"",
mrp:0,
discount:0,
price:0,
stock:0,
minstock:0,
outofstock:""}],
}));
}
deteteRow = (index) => {
this.setState({
varientDetails: this.state.varientDetails.filter((s, sindex) => index !== sindex),
});
}
handleSubmit = (e) => {
e.preventDefault();
console.log(this.state)
if(this.state.date==='' || this.state.description==='')
{
NotificationManager.error(" Error -Please Fill up all Required Field!!!");
return false;
}
for(var i=0;i<this.state.varientDetails.length;i++)
{
if(this.state.varientDetails[i].sort==='' || this.state.varientDetails[i].varient==='')
{
NotificationManager.error("Error- Product Varient Fields are required!!!");
return false;
}
}
const formData = new FormData();
for (const file of this.state.files) {
formData.append('file', file)
}
const config = {
Headers: {
'content-type': 'multipart/form-data',
"Content-Type": "multipart/form-data; boundary=AaB03x" +
"--AaB03x" +
"Content-Disposition: file" +
"Content-Type: png" +
"Content-Transfer-Encoding: binary" +
"...data... " +
"--AaB03x--",
"Accept": "application/json",
"type": "formData"
},
productId:this.state.id,
name:this.state.name,
description:this.state.description,
lableType:this.state.lableType,
photo:this.state.thumbNailphoto,
isTex:this.state.isTex,
GSTrate:this.state.GSTrate,
GSTtyp:this.state.GSTtyp,
HSNcode:this.state.HSNcode,
videoUpload:this.state.videoUpload,
// categoryId:this.state.categoryId,
// subCategoryId:this.state.subCategoryId,
tags:this.state.tags,
file:formData,
reccomendedProduct:this.state.reccomendedProduct,
varientDetails:this.state.varientDetails
};
console.log(this.state)
swal({
title: "Are you sure?",
text: "You want to Add New Product",
icon: "warning",
buttons: true,
dangerMode: true,
})
.then(async (success) => {
if (success) {
let list = await GetProductDetails.getUpdateProduct(config);
if (list) {
this.setState({ isLoaded: false })
this.props.history.push("/admin/mainproduct/list")
} else {
NotificationManager.error("Please! Check input field", "Input Field");
}
}
});
}
clickOnDelete(record) {
this.setState({
varientDetails: this.state.varientDetails.filter(r => r !== record)
});
}
render() {
let { varientDetails,subCategoryId,files,updateFile,loading,productphotos,categoryId,reccomendedProduct } = this.state//let { notes, date, description, varientDetails } = this.state
console.log(updateFile)
return (
<div className="container-fluid">
<div className="row">
<div className="col-lg-5 col-md-9 col-lg-6">
<h2 className="mt-30 page-title">Products</h2>
</div>
<div className="col-lg-5 col-md-3 col-lg-6 back-btn">
<button className='btntop btn text-light' onClick={(e) => this.handleBack()}><i className="fas fa-arrow-left" />cancle</button>
<button type="submit" onClick={this.handleSubmit} className='btntop btn text-light mx-2'>Add</button>
</div>
</div>
<ol className="breadcrumb mb-30">
<li className="breadcrumb-item">Dashboard</li>
<li className="breadcrumb-item">Products</li>
<li className="breadcrumb-item active">Edit Product</li>
</ol>
<hr></hr>
<div className='container'>
<form onChange={this.handleChange} >
<div className='row'>
<div className='col-sm-8'>
<div className='row'>
<div className='col-sm-8'>
<div className="form-group">
<label htmlFor="name" class="form-label">Title <em style={{ color: "tomato" }}>*</em></label>
<input type="text" id="name" value={this.state.name} name="name" class=" w3-input w3-border form-control" aria-describedby="passwordHelpBlock" />
</div>
</div>
<div className="col-lg-12 col-md-12">
<div className="form-group">
<label className="form-label">Description*</label>
<RichTextEditor
style={{ height: " 275.438px" }}
className="w3-input w3-border"
content={this.state.description}
handleContentChange={this.handleContentChange}
placeholder="insert text here..." />
</div>
</div>
<div className='col-sm-8 py-4'>
<div className="form-group row">
<label className="my-2">Lables</label>
<label className="btn opt mx-2 col-2 active"style={{backgroundColor: "blue",borderColor: "#449D44"}}>
<input type="radio" id="lableType" hidden name="lableType" autocomplete="off" checked="checked"/> None
</label>
<label className="btn opt col-2 mx-2"style={{backgroundColor: "#449D44",borderColor: "#449D44"}}>
<input type="radio" hidden id="lableType" name="lableType" value="veg" autocomplete="off" checked="checked"/> veg
</label>
<label className="btn opt mx-2 col-3" style={{backgroundColor: "#C9302C",borderColor: "#C9302C"}}>
<input type="radio" hidden id="lableType" name="lableType" value="None Veg" autocomplete="off" checked="checked"/> None Veg
</label>
</div>
</div>
<div className='col-sm-12'>
<div className="form-group">
<label htmlFor="inputPassword5" class="form-label">Tags</label>
{/* <input type="text" id="inputPassword5" class="w3-input w3-border form-control" aria-describedby="passwordHelpBlock"/> */}
<TagsEditor setStateOfTags={this.setStateOfTags} />
</div>
</div><br></br>
<div className='col py-4'>
<div className="form-group">
<input type="checkbox" name="isTex"value={this.state.isTex} id="isTex" data-toggle="switchbutton" checked data-onlabel="true" data-offlabel="false" data-onstyle="success" data-offstyle="danger" />
</div>
<label htmlFor="isTex" class="form-label">is Taxt Enable</label>
</div>
<div className='row'>
<div className='col-sm-4'>
<div className="form-group">
<label className="form-label">GST Rate<em style={{ color: "tomato" }}>*</em></label>
<input type="number" value={this.state.GSTrate} className=" w3-input w3-border form-control" name="GSTrate" id="GSTrate" />
</div>
</div>
<div className='col-sm-4'>
<div className="form-group">
<label className="form-label">GST Rate Type <em style={{ color: "tomato" }}>*</em></label>
<select id="GSTtyp" value={this.state.GSTtyp} name="GSTtyp" className=" w3-input w3-border form-control">
<option value={1}>Inclusive</option>
<option value={0}>Exclusive</option>
</select>
</div>
</div>
</div>
<div className='col-sm-4 py-2'>
<div className="form-group">
<label htmlFor="HSNcode" class="form-label">HSN Code</label>
<input type="text" value={this.state.HSNcode} name="HSNcode" className='w3-input w3-border form-control' id="HSNcode" aria-describedby="passwordHelpBlock" />
</div>
</div><br></br>
</div>
{/* now we are using varient dynamic form */}
<div className='varientheader py-4' style={{ paddingBottom: "15px" }}>
<a onClick={this.addNewRow} className="btn" style={{ float: 'right', color: "Tomato" }}><i class="fas fa-plus"></i>Add More</a>
<h3 style={{ float: 'left', }}>Varients</h3>
</div>
<hr style={{ padding: "2px", border: "2 px solid black" }}></hr>
<div className="container py-4" style={{ border: "lightgray" }}>
<VarientDetailEdit add={this.addNewRow} delete={this.clickOnDelete.bind(this)} varientDetails={varientDetails} />
</div>
<div className='recomended product'>
<hr></hr>
<h3>Recommended Products</h3>
<hr></hr>
<div className='ex1'>
<ReccomendedFormList rowRcData={reccomendedProduct} setStaterecomended={this.setStaterecomended} />
</div>
</div>
</div>
{/* right section cotegory */}
<div className='col-sm-4'>
<div>
<h3>Category <em style={{ color: "tomato" }}>*</em></h3>
<div className='mx-4 my-2'>
<div className='categorycontainer'>
<CategoryListEdit data={categoryId} sdata={subCategoryId} setStateOfCategory={this.setStateOfCategory} />
<hr></hr>
</div>
{/* file upload */}
<div className='imagecontainer'>
<h3>Upload Images</h3>
<hr />
<div className="wrapper">
<div className="drop">
<div className="cont">
<i className="fas fa-cloud-upload-alt"></i>
<div className="tit">
Drag & Drop
</div>
<div className="desc">
your files to Assets, or
</div>
<div className="browse">
click here to browse
</div>
</div>
<input id="files" multiple name="files[]" onChange={this.fileSelectedHandler} type="file" />
</div>
<ToastContainer autoClose={1500} />
</div>
{this.state.filselected ? <div><i>{this.state.filselected}</i>
{/* <div className="form-group">
<button className="save-btn hover-btn" type="submit" onClick={this.handleSubmitPhoto} disabled={loading}>
{loading && <i className="fa fa-refresh fa-spin" />}
{loading && <span>Upload</span>}
{!loading && <span>Upload</span>}
</button>
<ToastContainer autoClose={1500} />
</div> */}
</div>:
<p>Drag & Drop files here or click to browse.
Note: Max 4 images are allowed.</p>
}
<div style={{display:"flex",margin:"10px"}} >
{ productphotos.map((item,i)=>(
<div className="img_wrp mx-2">
<img width="60px" height="55px" value ={item.imgUrl} src={item.imgUrl} alt="video not found "/><i onClick={(e) =>this.handlawsDeleteById(item.id,item.imgUrl)} className="fa fa-close close"></i>
</div>
))}
</div>
<hr></hr>
</div>
<div className='uploadfile'>
<h3>Upload Video </h3>
<input type="file" className="form-control" onChange={this.VideoUploadFile} />
<p style={{ color: "blue",fontStyle:"italic",fontWeight:"bold" }}>{this.state.msgvideoUpload}</p>
<div className="img_wrp">
<img width="200px" height="150px" src={this.state.videoUpload} alt="video not found "/><i onClick={this.deletePhotoStaticVideo} className="fa fa-close close"></i>
</div>
{/* { this.state.uploadPercentage > 0 && <ProgressBar variant="danger" now={this.state.uploadPercentage} active label={`${this.state.uploadPercentage}%`} /> }<br></br> */}
<div className='upload thambnail my-4'>
<h3>Video Thumbnail Image</h3>
<div className="file-area">
<div className="form-group">
<input type="file" className="form-control" onChange={this.ThumbnainVideoUpload} />
<div className="file-dummy">
<i className="fas fa-plus mx-4 my-4"></i><br></br>
<span className="default">Click to select a file, or drag it here</span>
<span className="success">Great, your file is selected</span>
</div>
<p style={{ color: "blue",fontStyle:"italic",fontWeight:"bold" }}>{this.state.msgThumb}</p>
<div className="img_wrp">
<img width="200px" height="150px" src={this.state.thumbNailphoto} alt="thumbnail not found"/><i className="fa fa-close close" onClick={this.deletePhotoStaticThumb} ></i>
</div>
{/* {(() => {
if (!this.state.photo)
return <button onClick={this.handleCanclePhoto}>delete</button>
}
)} */}
{/* { this.state.uploadPercentage > 0 && <ProgressBar variant="danger" now={this.state.uploadPercentage} active label={`${this.state.uploadPercentage}%`} /> }<br></br> */}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
)
}
i have solve my problem.we have to use defaultValue for solve his problem
<input type="text" defaultValue={this.props.value || ''} />

Changing state in useEffect

I am dispatching an action in useEffect hook to fetch data and then updating state using the data from redux store. When the page first loads i get the correct data, but when refreshing the browser I get undefined values.
React.useEffect(() => {
dispatch(getSingleCoin(props.match.params.id))
setName(coinDetail.name)
setSymbol(coinDetail.symbol)
setLogourl(coinDetail.logo)
setPrice(coinDetail.price)
setLaunchDate(coinDetail.launchDate)
setWebsiteUrl(coinDetail.websiteUrl)
setNetwork(coinDetail.chain)
setAddress(coinDetail.address)
setTwitterUrl(coinDetail.twitter)
setTelegramUrl(coinDetail.telegram)
setRedditUrl(coinDetail.reddit)
setYoutubeUrl(coinDetail.youtube)
setCoinDescription(coinDetail.description)
setMarketCap(coinDetail.marketCap)
}
}, [coinDetail,dispatch, props.match.params.id])
const handleSubmit = (e) => {
e.preventDefault()
const coin = {}
coin.name = name
coin.symbol = symbol
coin.logo = logourl
coin.price = price
coin.launchDate = launchDate
coin.websiteUrl = websiteUrl
coin.chain = network
coin.address = address
coin.twitter = twitterUrl
coin.telegram = telegramUrl
coin.reddit = redditUrl
coin.youtube = youtube
coin.description = coinDescription
coin.marketCap = marketCap
coin._id = props.match.params.id
dispatch(updateCoin(coin))
}
return (
<div className="container add-coin-wapper mt-4">
{loading && coinDetail === undefined ? (
<div>...Loading</div>
) : error ? (
<div>{error}</div>
) : (
<div className="card ">
<div className="card-header">
<div className="approve-header">
<div
className="approve-back"
onClick={() => props.history.push('/Admin/coinlist')}
>
<ArrowBackIosIcon />
<div>Back to Coin listing</div>
</div>
</div>
</div>
<div className="card-body">
{/* here */}
<>
<div>
<h3>Edit Coin</h3>
</div>
<form onSubmit={handleSubmit}>
<div className="row">
<div className="col-sm-12 col-md-6 col-lg-6">
<h5>Coin informations</h5>
<div className="form-group">
<label htmlFor="name">name</label>
<input
type="text"
className="form-control"
id="name"
name="name"
placeholder="Bitcoin"
required
onChange={(e) => setName(e.target.value)}
value={name}
/>
</div>
<div className="form-group">
<label htmlFor="symbol">symbol</label>
<input
type="text"
className="form-control"
id="symbol"
name="symbol"
placeholder="Enter symbol"
onChange={(e) => setSymbol(e.target.value)}
required
value={symbol}
/>
</div>
<div className="form-group">
<label htmlFor="logo">Logo url</label>
<input
type="text"
className="form-control"
id="url"
name="logourl"
placeholder="https://clod.com/logo"
onChange={(e) => setLogourl(e.target.value)}
value={logourl}
/>
</div>
<div className="form-group">
<label htmlFor="description">Coin Description</label>
<textarea
className="form-control"
id="exampleFormControlTextarea1"
rows="3"
onChange={(e) => setCoinDescription(e.target.value)}
placeholder="Describe your coin appropriately to show attractiveness"
value={coinDescription}
></textarea>
</div>
<div className="form-group">
<label htmlFor="price">price</label>
<div className="input-group mb-2">
<div className="input-group-prepend">
<div className="input-group-text">$</div>
</div>
<input
type="number"
className="form-control"
id="marketcap"
placeholder="0.00085"
step="any"
min="0"
onChange={(e) => setPrice(e.target.value)}
value={price}
/>
</div>
</div>
<div className="form-group">
<label htmlFor="marketcap">Market cap</label>
<div className="input-group mb-2">
<div className="input-group-prepend">
<div className="input-group-text">$</div>
</div>
<input
type="number"
className="form-control"
id="marketcap"
step="any"
placeholder="0.00085"
min="0"
onChange={(e) => setMarketCap(e.target.value)}
value={marketCap}
/>
</div>
</div>
<div className="form-group">
<label htmlFor="launchdate">Launch date</label>
<div
className="input-group date"
data-provide="datepicker"
>
<input
type="date"
className="form-control"
onChange={(e) => setLaunchDate(e.target.value)}
value={moment(launchDate).format('YYYY-MM-DD')}
/>
<div className="input-group-addon">
<span className="glyphicon glyphicon-th"></span>
</div>
</div>
</div>
</div>
<div className="col-sm-12 col-md-6 col-lg-6">
<h5>Coin market</h5>
<div className="form-group">
<label htmlFor="network">Network/Chain</label>
<select
className="form-control"
id="network"
onChange={(e) => setNetwork(e.target.value)}
value={network}
>
<option value="BSC">Binance Smart Chain (BSC)</option>
<option value="ETH">Ethereum (ETH)</option>
<option value="SOL">Solona (SOL)</option>
</select>
</div>
<div className="form-group">
<label htmlFor="contract">Contract Adress</label>
<input
type="text"
className="form-control"
id="contract"
name="contract"
placeholder="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
onChange={(e) => setAddress(e.target.value)}
required
value={address}
/>
</div>
<h5>Coin links</h5>
<div className="form-group">
<label htmlFor="weburl">Website url</label>
<div className="input-group mb-2">
<div className="input-group-prepend">
<div className="input-group-text">
<LanguageIcon />
</div>
</div>
<input
type="text"
className="form-control"
id="web"
placeholder="https://www.coinx.com"
onChange={(e) => setWebsiteUrl(e.target.value)}
required
value={websiteUrl}
/>
</div>
</div>
<div className="form-group">
<label htmlFor="twitter">Twitter</label>
<div className="input-group mb-2">
<div className="input-group-prepend">
<div className="input-group-text">
<TwitterIcon />
</div>
</div>
<input
type="text"
className="form-control"
id="twitter"
placeholder="https://twitter.com/"
onChange={(e) => setTwitterUrl(e.target.value)}
value={twitterUrl}
/>
</div>
</div>
<div className="form-group">
<label htmlFor="telegram">Telegram</label>
<div className="input-group mb-2">
<div className="input-group-prepend">
<div className="input-group-text">
<TelegramIcon />
</div>
</div>
<input
type="text"
className="form-control"
id="telegram"
placeholder="https://t.me/"
onChange={(e) => setTelegramUrl(e.target.value)}
value={telegramUrl}
/>
</div>
</div>
<div className="form-group">
<label htmlFor="youtube">YouTube</label>
<div className="input-group mb-2">
<div className="input-group-prepend">
<div className="input-group-text">
<YouTubeIcon />
</div>
</div>
<input
type="text"
className="form-control"
id="youtube"
placeholder="https://www.youtube.com/watch?v="
onChange={(e) => setYoutubeUrl(e.target.value)}
value={youtube}
/>
</div>
</div>
<div className="form-group">
<label htmlFor="reddit">Reddit</label>
<div className="input-group mb-2">
<div className="input-group-prepend">
<div className="input-group-text">
<RedditIcon />
</div>
</div>
<input
type="text"
className="form-control"
id="reddit"
placeholder="https://www.reddit.com"
onChange={(e) => setRedditUrl(e.target.value)}
value={redditUrl}
/>
</div>
</div>
<button type="submit" className="btn" disabled={loading}>
update
</button>
</div>
</div>
</form>
</>
{/* here */}
</div>
{/* here */}
</div>
)}
</div>
The state data is supposed to be displayed in form input elements. I render a div with a loading status before the data is fetched and loading set to false.

how do I fix this ant design datepicker component in my react project .I have shared a screenshot

I'm working on a project which required ant design datepicker along with bootstrap.I'm not sure whats making this datepicker move out of screen. Is there something I need to do with bootstrap classes to fix this? I have shared my screenshot.thanenter image description here]1]1
const form= () => (
<form onSubmit={onFormSubmit}>
<div className="form-group">
<label className="btn btn-outline-secondary btn-block m-3">Add image
<input type="file" name="image" onChange={handleImageChange} accept="image/*" hidden/>
</label>
<input className="form-control m-2" type="text" name="title" placeholder="title" onChange={handleChange} value={title}/>
<textarea className="form-control m-2" type="text" name="content" placeholder="content" onChange={handleChange} value={content}/>
<AlgoliaPlaces className="form-control ml-2" placeholder="location" defaultValue={location} options={config} onChange={handleSearch} style={{height:"50px"}} />
<input className="form-control m-2" type="number" name="price" placeholder="price" onChange={handleChange} value={price}/>
<input className="form-control m-2" type="number" name="bed" placeholder="Number of beds" onChange={handleChange} value={bed}/>
</div>
**<DatePicker className="form-control m-2"/>**
<button className="btn btn-outline-primary m-2">Add</button>
</form>
)
return(
<div>
<div className="container-fluid p-5 text-center">
<h2>Add </h2>
</div>
<div className="container-fluid">
<div className="row">
<div className="col-md-10">
{hotelForm()}
</div
<div className="col-md-2">
<img src={preview} alt="preview-image" className="img img-fluid m-2" />
<pre>{JSON.stringify(values,null, 2)}</pre>
</div>
</div>
</div>
</div>
)
It looks like you are missing ant design css stylesheet.
Try to add the following line at the root of your app :
import 'antd/dist/antd.css';

How to implement secure remember username and password in react.js

<Formik
initialValues={LoginSchema}
validationSchema={LoginSchemaValidation}
onSubmit={(values, { setSubmitting, resetForm }) => {
this.handleSubmit(values);
setSubmitting(false);
resetForm();
}}
>
<Form>
<div className="input-group mb-3">
<Field name="username" type="email" className="form-control" placeholder="Email" />
<div className="input-group-append">
<div className="input-group-text">
<span>
<FontAwesomeIcon icon={faEnvelope} />
</span>
</div>
</div>
</div>
<p className="errors">
<ErrorMessage name="username" />
</p>
<div className="input-group mb-3">
<Field
name="password"
type="password"
className="form-control"
placeholder="Password"
/>
<div className="input-group-append">
<div className="input-group-text">
<span>
<FontAwesomeIcon icon={faLock} />
</span>
</div>
</div>
</div>
<p className="errors">
<ErrorMessage name="password" />
</p>
<div className="input-group mb-3">
<label>
<Field name="isRemember" type="checkbox"/> Remember Me
</label>
</div>
<div className="row">
<div className="col-12">
<button type="submit" className="btn btn-yellow btn-block">
Sign In
</button>
</div>
</div>
</Form>
</Formik>
This is my react form for user input, i used spring boot as backend.
Now i want to implement remember me feature at front-end
Is it secure to store username and password in local storage?
If not then how should i implement this functionality?

Resources