“wie man Variablen an Makestles übergeht” Code-Antworten

Gib Requisis an die materielle Benutzeroberfläche

import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
import {Theme} from '@material-ui/core';

export interface StyleProps {
    height: number;
}

const useStyles = makeStyles<Theme, StyleProps>(theme => ({
  root: {
    background: 'green',
    height: ({height}) => height,
  },
}));

export default function Hook() {

  const props = {
    height: 48
  }

  const classes = useStyles(props);
  return <Button className={classes.root}>Styled with Hook API</Button>;
}
Cautious Coyote

Gib Requisiten an Makestles

const useStyles = props => makeStyles( theme => ({
    div: {
        width: theme.spacing(props.units || 0)  
    }
}));

//calling the function
const classes = useStyles(props)();
Graceful Gerenuk

wie man Variablen an Makestles übergeht

import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
import {Theme} from '@material-ui/core';

const useStyles = makeStyles(theme => ({
  root: {
    background: ({color})=> color,
  },
}));

export default function Hook() {
  const props = {
    color: "#1D3874"
  }
  const classes = useStyles(props);
  return <Button className={classes.root}>Styled with Hook API</Button>;
}
Silly Shrike

Ähnliche Antworten wie “wie man Variablen an Makestles übergeht”

Fragen ähnlich wie “wie man Variablen an Makestles übergeht”

Weitere verwandte Antworten zu “wie man Variablen an Makestles übergeht” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen