Title component usage does not override existing title

Đang mở
#6,976 2 bình luận 2 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
react, typescript
Lĩnh vực
frontend

Hướng nghiên cứu

Bắt đầu tại điểm vào của component Title trong react-admin và theo dõi cách nhiều component Title được render đóng góp vào tiêu đề tài liệu. Tái hiện ví dụ về parent và child có điều kiện, sau đó xác minh rằng Title được render gần đây nhất thay thế tiêu đề hiện có thay vì nối thêm vào đó.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Is your feature request related to a problem? Please describe.
I have a page that conditionally renders child components. The page uses react-admin's Title component to set a title. In most cases, when child component is rendered, Title should stay the same as in parent component; however, in some conditions, we want to be able to override page's title from within child.

Today, if both parent and child component have Title rendered, react-admin will just append Title2 to Title1 (will show Title1Title2)

function ParentComponent = (props) => {
 const conditional = props.display? <ConditionalChild /> : null
 return (
   <Fragment>
     <Title title="Title1">
     Welcome to ParentComponent 
     {conditional}
  </Fragment>
  )
}


function ConditionalChild = () => {
 const status = fetch_status()
  if (status===0) 
    return (
     <Fragment>
       <Title title="Title2">
       Status 0
     </Fragment>
    )
  else 
    return (
     <Fragment>
       Other status
     </Fragment>
    )
}

Describe the solution you'd like
if a component or its children have multiple Title calls, the last call should win (similar to what react-helmet does while setting page title)

Describe alternatives you've considered
No clear solution found

Additional context
none

Ngôn ngữ chính
TypeScript
Star
27k
Fork
5.5k
Merge trung bình
1 ngày 3 phút
Pull request đã merge (30 ngày)
32

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của marmelab/react-admin

Tất cả issue của marmelab/react-admin

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.