B
B
BaronSmile2021-02-14 13:29:20
JavaScript
BaronSmile, 2021-02-14 13:29:20

How to make the correct checkbox filter logic?

Dear programmers need help to make correct CODE filter logic

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2021-02-14
@BaronSmile

Yes, everything is already done. You just need to cut out the excess. Why does the SidebarItem component pull something from redux? No need. Its task is to show the checkbox in the specified state, set the event handler passed from the parent. Everything:

export default ({ filter, checked, onChange, children }) => (
  <div>
    <label>
      <input
        type="checkbox"
        name={filter}
        onChange={() => onChange(filter)}
        checked={checked}
      />
      {children}
    </label>
  </div>
);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question