Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react onclick runs on load

<Button onClick={() => yourFunction(params)} />
Comment

load a component on button click react

import React from 'react';
import Grid from '@material-ui/core/Grid';
import Button from '@material-ui/core/Button';
import CssBaseline from '@material-ui/core/CssBaseline';
import Card from '@material-ui/core/Card';
import CardContent from '@material-ui/core/CardContent';
import withStyles from '@material-ui/core/styles/withStyles';

const styles = theme => ({
    card: {
        minWidth: 350,
    },
    button: {
        fontSize: '12px',
        margin: theme.spacing.unit,
        minWidth: 350
    },
    extendedIcon: {
        marginRight: theme.spacing.unit,
    }
});

class MainPage extends React.Component {
    constructor() {
        super();
    }

    render() {
        const {
            classes
        } = this.props;

        return ( <
            React.Fragment >
            <
            CssBaseline / >
            <
            Grid container spacing = {
                0
            }
            direction = "column"
            alignItems = "center"
            justify = "center"
            style = {
                {
                    minHeight: '100vh'
                }
            } >
            <
            form onSubmit = {
                this.handleSubmit
            } >
            <
            Card className = {
                classes.card
            } >
            <
            CardContent >
            <
            Grid item xs = {
                3
            } >
            <
            Button variant = "contained"
            size = "medium"
            color = "primary"
            className = {
                classes.button
            }
            type = "submit"
            value = "single" >
            ButtonA <
            /Button> <
            /Grid> <
            Grid item xs = {
                3
            } >
            <
            Button variant = "contained"
            size = "medium"
            color = "primary"
            className = {
                classes.button
            }
            type = "submit"
            value = "batch" >
            ButtonB <
            /Button> <
            /Grid> <
            /CardContent> <
            /Card> <
            /form> <
            /Grid> <
            /React.Fragment>
        );
    }
}

export default withStyles(styles)(MainPage);
Comment

PREVIOUS NEXT
Code Example
Javascript :: open new window javascript 
Javascript :: spread operator in javascript 
Javascript :: try catch in react native 
Javascript :: javascript play audio from buffer 
Javascript :: filter an array of objects and match its key with values inside another array 
Javascript :: export default react 
Javascript :: Find the next perfect square! 
Javascript :: js check if string is int 
Javascript :: nested for loop js 
Javascript :: React 18 to 17 
Javascript :: how to dynamic title in nuxt 
Javascript :: javascript style inline react 
Javascript :: jQuery hello world program 
Javascript :: js .then mean 
Javascript :: react big calendar event color 
Javascript :: elasticsearch bulk json 
Javascript :: js hoisting 
Javascript :: generate uuid from string js 
Javascript :: days in the current month 
Javascript :: javascript date format dd-mm-yyyy 
Javascript :: is digit javascript 
Javascript :: get element by name in jquery 
Javascript :: how to compare arrays in js 
Javascript :: how to disable right click of mouse on web page 
Javascript :: js sleep function with argument 
Javascript :: find highest number in array javascript 
Javascript :: js get index from foreach 
Javascript :: check user login or not in Shopify 
Javascript :: prevent redirect javascript 
Javascript :: react-select 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =