Unterminated JSX contents - meteor

In a meteor app, I am trying to render a login form using React.
import React from 'react';
export default class Login extends React.Component {
render() {
return (
<div class="login-card">
<h1>Log-in</h1><br>
<form>
<input type="text" name="user" placeholder="Username" />
<input type="password" name="pass" placeholder="Password" />
<input type="submit" name="login" class="login login-submit" value="login" />
</form>
<a class="login-help" href="#">Register</a>
</div>
);
}
}
But metor is unable to compile the above jsx file and says .
While processing files with ecmascript (for target web.browser):
client/loginForm.jsx:15:8: Unterminated JSX contents (15:8)
What can be the reason?

You need to close br element, in react always use selft close tags, and also dont use class use className instead
import React from 'react';
export default class Login extends React.Component {
render() {
return (
<div className="login-card">
<h1>Log-in</h1><br/> // Close br
<form>
<input type="text" name="user" placeholder="Username" />
<input type="password" name="pass" placeholder="Password" />
<input type="submit" name="login" className="login login-submit" value="login" />
</form>
<a className="login-help" href="#">Register</a>
</div>
);
}
}

import React from 'react';
export default class Login extends React.Component {
render() {
return (
<div class="login-card">
<h1>Log-in</h1><br></br>
<form>
<input type="text" name="user" placeholder="Username" />
<input type="password" name="pass" placeholder="Password" />
<input type="submit" name="login" class="login login-submit" value="login" />
</form>
<a class="login-help" href="#">Register</a>
</div>
);
}
}
Close the br tag

Related

Issues manipulating css with react

hope any of you could help me out in here...
On the code below I have 2 separete elements which I want to show one at the time.
first element is an iframe
second is a Div
the ideia is if the user click on the {title} then the frame disaper and the div appear.
I can manage to make the frame disapper and appear by clicking on the title, but the same does not happen with the div.
the code is basically the same, so I don't really get why is the div not having the same behavior then the frame.
Also I double checked and both css classes get changed as expected, just that the css class seems not to work on the Div.
Tks in advance.
import React, { useState } from 'react';
const Card = (props) => {
const { id, title, active, site, img } = props.data;
const [content, setContent] = useState(false);
return (
<div className={`card ${active && 'active'}`} >
<img id='img_cover' src={img} alt='image01' onClick={() => props.onCardClick(id)}></img>
<div className='txt'>
<h2 onClick={() => setContent(!content)}>{title}</h2>
</div>
<iframe className={`${content ? 'content_site' : 'content_frame'}`} src={site} frameborder="0" title={title}>
</iframe>
<div className={`${content ? 'content_frame' : 'content_site'}`}>
<form id="contact-form" action="#" className="table">
<input className='input_espace row' id='nome' placeholder="Name" name="name" type="text" required />
<input className='input_espace row' id='email' placeholder="Email" name="email" type="email" required />
<textarea id="text_area" className='row' cols="50" placeholder="Message" type="text" name="message" />
<button type="button" class="btn btn-outline-warning button_submit"> Enviar</button>
</form>
</div>
</div >
)
}
export default Card;
className={`${content ? 'content_site' : 'content_frame'}`}
and
className={`${content ? 'content_frame' : 'content_site'}`}
are contrandicting each other because both are expecting content to be true change one to be !content
change the second one as you can see in your method setContent(!content)}
like this:
import React, { useState } from 'react';
const Card = (props) => {
const { id, title, active, site, img } = props.data;
const [content, setContent] = useState(false);
return (
<div className={`card ${active && 'active'}`} >
<img id='img_cover' src={img} alt='image01' onClick={() => props.onCardClick(id)}></img>
<div className='txt'>
<h2 onClick={() => setContent(!content)}>{title}</h2>
</div>
<iframe className={`${content ? 'content_site' : 'content_frame'}`} src={site} frameborder="0" title={title}>
</iframe>
<div className={`${!content ? 'content_frame' : 'content_site'}`}>
<form id="contact-form" action="#" className="table">
<input className='input_espace row' id='nome' placeholder="Name" name="name" type="text" required />
<input className='input_espace row' id='email' placeholder="Email" name="email" type="email" required />
<textarea id="text_area" className='row' cols="50" placeholder="Message" type="text" name="message" />
<button type="button" class="btn btn-outline-warning button_submit"> Enviar</button>
</form>
</div>
</div >
)
}
export default Card;

<form> is wrapped by custom Card component in react. How to style with them in external css file

<Card className="input">
<form onSubmit={addUserHandler} className="input">
<label htmlFor="username">Username</label>
<input id="username" type="text" />
<label htmlFor="age">Age (Years)</label>
<input id="age" type="text" />
<button type="submit">Add User</button>
</form>
</Card>
Now the Card component below.
return <div className="card">{props.children}</div>;
How to align this two for css styling?
css
.card > .input-form {
background-color: gray
}
code as below
<Card className="input">
<form onSubmit={addUserHandler} className="input-form">
<label htmlFor="username">Username</label>
<input id="username" type="text" />
<label htmlFor="age">Age (Years)</label>
<input id="age" type="text" />
<button type="submit">Add User</button>
</form>
</Card>
Now the Card component below.
return <div className="card">{props.children}</div>;

Angular Object is possibly 'null'. Error at <span *ngIf="checkoutForm.get('emailAddr').hasError('required')">Enter email address</span>

Hi I am new to Angular 11 can anyone please help me with this error -
This is my code.
checkout.component.html
<h3>Checkout forms - Using Reactive forms</h3>
<div class="container">
<form [formGroup]="checkoutForm" (ngSubmit)="postData();">
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email" name="emailAddressField" formControlName="emailAddr">
<span *ngIf="checkoutForm.get('emailAddr').hasError('required')">Enter email address</span>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Quantity</label>
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password" name="passwordField" formControlName="quantity">
<small id="emailHelp" class="form-text text-muted">Enter Quantity</small>
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="exampleCheck1" name="termsField" formControlName="terms">
<label class="form-check-label" for="exampleCheck1">Agree to Terms</label>
</div>
<br>
<button type="submit" class="btn btn-primary" [disabled]="!checkoutForm.valid">Checkout</button>
</form>
</div>
I am getting error as Error at <span *ngIf="checkoutForm.get('emailAddr').hasError('required')">Enter email address
checkout.component.ts
import { Component, Input, OnInit } from '#angular/core';
import { FormGroup, FormControl, FormBuilder,Validators} from '#angular/forms';
#Component({
selector: 'app-checkout',
templateUrl: './checkout.component.html',
styleUrls: ['./checkout.component.css']
})
export class CheckoutComponent implements OnInit {
checkoutForm:FormGroup;
constructor(private formBuilder:FormBuilder) {
this.checkoutForm = formBuilder.group({
emailAddr: ['',Validators.required],
quantity: ['',Validators.required],
terms: ['',Validators.requiredTrue]
});
}
ngOnInit(): void {
}
postData(){
console.log(this.checkoutForm);
}
}
Instead of using
<span *ngIf="checkoutForm.get('emailAddr').hasError('required')">Enter email address</span>
Try
<span *ngIf="checkoutForm.get('emailAddr')?.hasError('required')">Enter email address</span>
i have tested this code on my computer maybe it will also help you to resolve your compilation error.
You can use *ngIf="cadastroForm.get('username')?.errors">.
You have to use the ?.

Obtain data from a form in wordpress

I'm building a wordpress website using Avada tamplate. I use the Avada login form in which the users insert their username and password. I would like to get the username of the user when he click on the form button and he's redirect to login.php page. I don't understand why I can't do that.
The code of the form (i removed "class" and "style" in order to reduce it) is:
<form name="loginform" id="loginform" method="post" action="http://www.mywebsite.com/es/wp-login.php">
<div>
<div>
<label for="user_login">Username</label>
<input type="text" name="log" placeholder="Username" value="" size="20" id="user_login" />
</div>
<div>
<label for="user_pass">Password</label>
<input type="password" name="pwd" placeholder="Password" value="" id="user_pass" />
</div>
</div>
<div>
<div>
<button type="submit" name="wp-submit">Log in</button>
<input type="hidden" name="user-cookie" value="1" />
<input type="hidden" name="redirect_to" value="login.php" />
<input type="hidden" name="fusion_login_box" value="true" />
<input type="hidden" name="_wp_http_referer" value="/es/area-privada/" /><span></span></div>
<div></div>
</div>
</form>
The login.php code is very simple:
<?php
$username = $_POST['log'];
echo $username;
?>
however the variable $username is blank and doesn't capture the username. Someone can help me please? thanks!

Pure css nothing has margin

<form className="pure-form">
<fieldset>
<input ref="email" type="email" placeholder="Email"
value={this.state.emailInput}
onChange={this.handleChange}
/>
<input ref="password" type="password" placeholder="Password"
value={this.state.passwordInput}
onChange={this.handleChange}
/>
<label htmlFor="remember">
<input ref="remember" id="remember" type="checkbox" /> Remember me?
</label>
<button onClick={this.handleLoginClick} type="submit" className="pure-button pure-button-primary">Sign in</button>
</fieldset>
</form>
I just copy-pasted the example form from Purecss.io.
How come everything sticks together? Why do they have no margin?
You have the classes incorrectly added:
<form className="pure-form">
should be
<form class="pure-form">
...and so on.
<link href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css" rel="stylesheet" />
<form class="pure-form">
<fieldset>
<input red="email" type="email" placeholder="Email" />
<input ref="password" type="password" placeholder="Password" />
<label htmlFor="remember">
<input ref="remember" id="remember" type="checkbox" />Remember me?
</label>
<button onClick={this.handleLoginClick} type="submit" class="pure-button pure-button-primary">Sign in</button>
</fieldset>
</form>
Paulie_D is correct if you want to call any css class on any html tag then you need to follow the syntax like this
<tag class="classname"></tag>
Eg:
<form class="pure-form">
form elements goes here
</form>

Resources