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 :: local 
Javascript :: counting pairs in an array, resulting in a given sum 
Javascript :: how to count characters 
Javascript :: /function 
Javascript :: js if statement 
Javascript :: Plugin "react" was conflicted between "package.json » eslint-config-react-app 
Javascript :: add value to object 
Javascript :: useReducer Hooks 
Javascript :: open source 
Javascript :: scribbletune 
Javascript :: update url parameters and create history entry 
Javascript :: giphy javascript github 
Javascript :: react and node js sample project github 
Javascript :: aria labelledby js 
Javascript :: javascript firestore autoID 
Javascript :: js let vs var performance 
Javascript :: how to print array of 52/ print it 5 times with different value in javascript 
Javascript :: angular print an array 
Javascript :: for (var i = 0; i < 10; i++) { setTimeout(function () { console.log(i) }, 10) } What 
Javascript :: return <Text using if condition react native 
Javascript :: formatar data com jquery 
Javascript :: warn user before leaving page angular 
Javascript :: nsenter 
Javascript :: predicate logic solver 
Javascript :: laravel pass collection to javascript 
Javascript :: checkPalindrome 
Javascript :: bookshelfjs npm 
Javascript :: firebase remove not valid token 
Javascript :: unable to save shipping information. please check input data. magento 2 
Javascript :: add delay for keypress event in extjs 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =