惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
腾讯CDC
M
MIT News - Artificial intelligence
Y
Y Combinator Blog
L
LangChain Blog
Vercel News
Vercel News
云风的 BLOG
云风的 BLOG
GbyAI
GbyAI
Stack Overflow Blog
Stack Overflow Blog
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
The GitHub Blog
The GitHub Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
B
Blog
P
Proofpoint News Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园_首页
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
IT之家
IT之家
A
About on SuperTechFans
H
Help Net Security

szhshp 的第三边境研究所

假设, AI 把我代替的那一刻真的到来 | szhshp 的第三边境研究所 小傻瓜都能懂的 AstrBot QQ 机器人集成 MCP 功能实战指南 | szhshp 的第三边境研究所 《智人之上: 从石器时代到 AI 时代的信息网络简史》阅读笔记 | szhshp 的第三边境研究所 iPadOS 26 无法设置空间场景图片壁纸的解决方法 | szhshp 的第三边境研究所 《一路云海》(终) | szhshp 的第三边境研究所 《一路云海》(四): 如何不按套路旅行 | szhshp 的第三边境研究所 《一路云海》(三): In Ya Mellow Tone | szhshp 的第三边境研究所 《一路云海》(二): 关西世博参观纪实 | szhshp 的第三边境研究所 《一路云海》(一): 新的征程 | szhshp 的第三边境研究所 2025 大阪世博会 [ 3 天前-先到先得 ] 阶段 场馆预约必中独家攻略 | szhshp 的第三边境研究所 Hackathon 随想 | szhshp 的第三边境研究所 一杯双皮奶 | szhshp 的第三边境研究所 Armbian + CasaOS + NAS 配置指南 | szhshp 的第三边境研究所 Docker 构建镜像报错: error getting credentials - err: exit status 1, out: `` | szhshp 的第三边境研究所 Disqus RIP! 论过高的维护成本如何治疗固执的坏习惯 | szhshp 的第三边境研究所 炸弹猫桌游变体规则 | szhshp 的第三边境研究所 《小岛经济学》阅读笔记 | szhshp 的第三边境研究所 《金钱心理学》阅读笔记 | szhshp 的第三边境研究所 为知笔记 RIP: 迁移剩余的笔记 | szhshp 的第三边境研究所 2025 博客第十年展望 - 再见我的过去 | szhshp 的第三边境研究所 我在独立游戏里面致敬的作品 | szhshp 的第三边境研究所 《How to make thing faster》阅读笔记 | szhshp 的第三边境研究所 《The Art of Clean Code》阅读笔记 | szhshp 的第三边境研究所 《Clean Architecture: A Craftsman Guide to Software Structure and Design》阅读笔记 | szhshp 的第三边境研究所 《How AI Works》阅读笔记 | szhshp 的第三边境研究所 游戏策划废案 - Project Uranus | szhshp 的第三边境研究所 游戏策划废案 - Project X | szhshp 的第三边境研究所 人生第一款独立游戏开发复盘 | szhshp 的第三边境研究所 Trap of Life | szhshp 的第三边境研究所 如果我用手搓了个暗物质雏形 | szhshp 的第三边境研究所
React Semantic UI-CheatSheet | szhshp 的第三边境研究所
2020-01-27 · via szhshp 的第三边境研究所

Meta

目录

Confirm as Modal

Tags: React, CSS, Modal, Semantic UI, actions, trigger

Example

<Button.Group>
  <Button>
    <Icon name="history" />
  </Button>
  <Button>
    <Icon name="edit" />
  </Button>
  <Modal
    trigger={(
      <Button
        icon
        title="Delete Employee"
      >
        <Icon name="trash" />
      </Button>
    )}
    header="Alert!"
    content="If you delete this employee then all related data"
    actions={[
      {
        key: 'yes',
        content: 'Yes',
        positive: true,
        onClick: () => {
          console.log(123);
        },
      },
      { key: 'no', content: 'No' },
    ]}
  />
</Button.Group>
  • If we used trigger then it will be rendered as HTML code specified. (Usually we may render it as a button)
  • We may render each action button per provided objects in attribute actions
    • In the above example, we may render 2 action buttons:
      1. Yes Button with on click event
      2. No Button without any binded event

Get Dropdown/Selector Value

Tags: React, Semantic UI, selector, value, selected option, dropdown

event.target.value is undefined from event:onChange of Dropdown in Semantic UI

Example

Simply reach the second argument to get the value:

<Select
  placeholder="Select An Employee"
  options={props.employees}
  value={props.employeeId}
  title="employeeId"
  onChange={(e, res) => {
    const { title, value } = props;
    // title = employeeId
    // value = option value
  }}
/>

onChange Template

/* only for dropdown */
handleDropdownChange (props, e) {
  const { name, value } = props
  // ...
}

/* only for inputs */
handleInputChange (props, e) {
  const { name, value } = props
  // ...
}

Capture Form Inputs

For form inputs we can also capture the input via second argument

handleChange = (e, { name, value }) => this.setState({ [name]: value })

render() {
  const { name, email, submittedName, submittedEmail } = this.state

  return (
    <div>
      <Form onSubmit={this.handleSubmit}>
        <Form.Group>
          <Form.Input
            placeholder='Name'
            name='name'
            value={name}
            onChange={this.handleChange}
          />
          <Form.Input
            placeholder='Email'
            name='email'
            value={email}
            onChange={this.handleChange}
          />
          <Form.Button content='Submit' />
        </Form.Group>
      </Form>
      <strong>onChange:</strong>
      <pre>{JSON.stringify({ name, email }, null, 2)}</pre>
      <strong>onSubmit:</strong>
      <pre>{JSON.stringify({ submittedName, submittedEmail }, null, 2)}</pre>
    </div>
  )
}

See full instruction: https://react.semantic-ui.com/collections/form/#usage-capture-values

Reference

https://react.semantic-ui.com/modules/modal/#types-shorthand