Image for post
Image for post
Photo by Chris Chow on Unsplash

REACT DOC SERIES

React Docs -3 (Code Sharing)

Bu yazıda kod paylaşımı için HOC (High Order Components) ve Render Props yöntemlerini analiz ediyor olacağım.

Onur Dayıbaşı
Nov 30, 2020 · 4 min read

1. High Order Components

Image for post
Image for post
High Order Component Sample WithRouter and Redux

Argümanlarında 1 yada 1 den fazla function referansını parametre olarak alan veya return değerini geriye fonksiyon olarak dönen fonksiyonlara High Order Functions denir.

HOC’de Argümanlarında bir veya birden fazla bileşeni alıp, geriye Bileşen dönen ve bu kapsama sırasında bu bileşenlere ekstra güçler kazandırmayı sağlar

Image for post
Image for post
https://reactjs.org/docs/higher-order-components.html (CommentList, BlogPost)
Image for post
Image for post
https://reactjs.org/docs/higher-order-components.html (CommentListSubs, BlogPostWithSubs)
Image for post
Image for post
https://reactjs.org/docs/higher-order-components.html (withSubscription)
// ... and renders the wrapped component with the fresh data!
// Notice that we pass through any additional props
return <WrappedComponent data={this.state.data} {...this.props} />;

2. Render Props

Senaryo

Image for post
Image for post
https://reactjs.org/docs/render-props.html (MouseTracker Mouse)
Image for post
Image for post
https://reactjs.org/docs/render-props.html (MouseWithCat)
Image for post
Image for post
https://reactjs.org/docs/render-props.html (Mouse render Props)
Image for post
Image for post
https://reactjs.org/docs/render-props.html (Mouse render Props)

3. Hooks

Referanslar

Frontend Development With JS

Frontend Development With Javascript

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store