ElemeFE / ElemeFE/element-react
<Button> onClick() not working as expected.
- Dominant language
- JavaScript
- Stars
- 2.8k
- Forks
- 435
- PR merge metrics
- No merged PRs in 30d
Description
onClick() not firing when using the custom component.
This works with vanilla buttons, but the button component does not fire the onClick() when clicked using the element-react button component.
```
import React, { useState } from "react";
import { Button } from 'element-react';
import 'element-theme-default';
function Todo({todo,index, completeTodo, deleteTodo, markImportant}){
return(
{todo.text}
)
}
function App(){
const[todos, setTodos] = useState([
{text: "1st Todo",
isCompleted:true,
isImportant:false},
{text: "Buy Milk",
isCompleted:false,
isImportant:false},
{text: "Last Todo",
isCompleted:false,
isImportant:false}
]);
const completeTodo = index => {
const allTodos = [...todos];
allTodos[index].isCompleted ? allTodos[index].isCompleted = false : allTodos[index].isCompleted = true;
setTodos(allTodos);
}
return (
{todos.map((todo,index) => (
))}
)
}
export default App;
```
What am I doing wrong?
Contributor guide
Assessment
This issue has not been assessed yet.