How to use the effector-react.createComponent function in effector-react

To help you get started, we’ve selected a few effector-react examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zerobias / effector / website / editor / src / logs / view.js View on Github external
//@flow

import * as React from 'react'
import {logs} from './domain'
import Console from '../components/Console'
import {createComponent} from 'effector-react'

export const LogsView = createComponent<
  {|
    style: any,
  |},
  Array<{|
    data: Array,
    id: number,
    method: *,
  |}>,
>(logs, ({style}, logs) => (
  
))
github zerobias / effector / website / editor / src / components / SecondanaryTabs.js View on Github external
padding: 7px 15px;
  margin: 0;
  background-color: ${({isActive}) => (isActive ? 'white' : 'inherit')};
  border-bottom: ${({isActive}) => (isActive ? '1px solid #fff' : 'none')};
  margin-bottom: ${({isActive}) => (isActive ? '-1px' : '0')};
`

const TabContent = styled.div`
  overflow: auto;
`

const TabView = createComponent(tab, ({}, tab) => (
  {tab === 'console' && }
))

const ToolbarView = createComponent(tab, ({}, tab) => (
  <ul>
    
      Console
    
  </ul>
))

const SecondanaryTabs = styled.div`
  display: flex;
  flex-direction: column;
  background: #fff;
  border-left: 1px solid #ddd;

  @media (max-width: 699px) {
    grid-column: 1 / span 1;
    grid-row: 11 / span 1;
github zerobias / effector / website / editor / src / view.js View on Github external
markLine={codeMarkLine}
        setCursor={codeSetCursor}
        performLint={performLint}
        onCursorActivity={codeCursorActivity}
        value={sourceCode}
        mode={mode}
        onChange={changeSourcesDebounced}
        lineWrapping
        passive
      /&gt;
      
    
  ),
)

const VersionLinkView = createComponent(version, ({}, version) =&gt; (
  
))

//const versions = useStore(packageVersions)
//const selected = useStore(version)
//TODO: bug in createComponent, probably actually in watchers
//,
const VersionSelectorView = createComponent(
  {versions: packageVersions, selected: version},
  (_, {versions, selected}) =&gt; (
    
  ),
github zerobias / effector / website / editor / src / components / SecondanaryTabs.js View on Github external
padding: 7px 15px;
  margin: 0;
  background-color: ${({isActive}) =&gt; (isActive ? 'white' : 'inherit')};
  border-bottom: ${({isActive}) =&gt; (isActive ? '1px solid #fff' : 'none')};
  margin-bottom: ${({isActive}) =&gt; (isActive ? '-1px' : '0')};
`

const TabContent = styled.div`
  overflow: auto;
`

const TabView = createComponent(tab, ({}, tab) =&gt; (
  {tab === 'console' &amp;&amp; }
))

const ToolbarView = createComponent(tab, ({}, tab) =&gt; (
  
    
      Console
    
  
))

const SecondanaryTabs = styled.div`
  display: flex;
  flex-direction: column;
  background: #fff;
  border-left: 1px solid #ddd;

  @media (max-width: 699px) {
    grid-column: 1 / span 1;
    grid-row: 11 / span 1;
github zerobias / effector / examples / react-ssr / src / app / App.js View on Github external
const EventsWrapper = Card.extend`
 grid-area: events;
 display: grid;
 grid-template-columns: 10rem;
 grid-gap: 1rem;
`

const Main = styled.main`
 display: grid;
 grid-gap: 1rem;
 grid-template-areas:
  'header header'
  'events code';
`

const TodoList = createComponent(todosView, (props: {||}, state) =&gt; (
 
  
   
    Events
   
   +
  
  {state.map(item =&gt; )}
 
))

export const App = () =&gt; (
 <main>
  <header>
  
  <code></code></header></main>
github zerobias / effector / examples / react-ssr / src / app / App.js View on Github external
const EventsHeader = styled.div`
 display: flex;
 justify-content: space-between;
`

const Item = ({text}) =&gt; (
 
  Event
  {text}
 
)
const CodeBox = Card.extend`
 grid-area: code;
`
const Code = createComponent(codeSource, (_: {||}, source) =&gt; (
 
  Source code
  <code>{source.map((line, i) =&gt; <p>{line}</p>)}</code>
 
))
const EventsWrapper = Card.extend`
 grid-area: events;
 display: grid;
 grid-template-columns: 10rem;
 grid-gap: 1rem;
`

const Main = styled.main`
 display: grid;
 grid-gap: 1rem;
 grid-template-areas:
github zerobias / effector / recipes / media-queries / viewReact.js View on Github external
//@flow

import * as React from 'react'
import {createComponent} from 'effector-react'
import {screenQueries} from './screenQueries'
import {orientationCheck, screenSizeCheck} from './queryCheck'

export const Screen = createComponent&lt;
  {
    children: React.Node,
    small?: boolean,
    medium?: boolean,
    large?: boolean,
    portrait?: boolean,
    landscape?: boolean,
    ...
  },
  {|
    large: boolean,
    medium: boolean,
    portrait: boolean,
    small: boolean,
  |},
&gt;(screenQueries, (props, queries) =&gt; {
github zerobias / effector / website / try / components / Stats.js View on Github external
if (tab === 'dom') return 'dom'
  if (event.length &gt; 0) return 'events'
  if (store.length &gt; 0) return 'storages'
  if (effect.length &gt; 0) return 'effects'
  if (domain.length &gt; 0) return 'domains'
  return 'events'
})
const api = createApi(tab, {
  showEvents: () =&gt; 'events',
  showStorages: () =&gt; 'storages',
  showEffects: () =&gt; 'effects',
  showDomains: () =&gt; 'domains',
  showDOM: () =&gt; 'dom',
})

const TabView = createComponent(tab, ({event, store, effect, domain}, tab) =&gt; {
  //TODO: unify this
  const className = `tab-content ${cx(
    tab === 'events' &amp;&amp; 'show-events',
    tab === 'storages' &amp;&amp; 'show-storages',
    tab === 'effects' &amp;&amp; 'show-effects',
    tab === 'domains' &amp;&amp; 'show-domains',
    tab === 'dom' &amp;&amp; 'show-dom',
  )}`
  const mapper = item =&gt; {
    const name = item?.compositeName?.fullName || item?.shortName || item.id
    return <li>{name}</li>
  }
  return (
    <div>
      {tab === 'events' &amp;&amp; (
        <div></div></div>
github howtocards / frontend / src / features / cards / organisms / cards-list.js View on Github external
const card = getCard(cardId)
  if (card) {
    setUsefulMark({ cardId: card.id, isUseful: !card.meta.isUseful })
  }
}

const selectCards = (props) =&gt;
  $registry.map((reg) =&gt; props.ids.map((id) =&gt; reg[id]))

type Props = {
  ids: number[],
  renderCard?: (param: { card: Card, onUsefulClick: () =&gt; * }) =&gt; React.Node,
  renderEmpty?: () =&gt; React.Node,
}

export const CardsList = createComponent(
  selectCards,
  ({ renderCard = defaultCardRender, renderEmpty = emptyRenderer }, cards) =&gt; (
     (
        
          {list.filter(Boolean).map((card) =&gt;
            renderCard({
              card,
              onUsefulClick: () =&gt; handleUsefulClick(card.id),
            }),
          )}
        
      )}
      renderEmpty={renderEmpty}
    /&gt;
github zerobias / effector / website / editor / src / components / SecondanaryTabs.js View on Github external
border-right: 1px solid #ddd;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  padding: 7px 15px;
  margin: 0;
  background-color: ${({isActive}) =&gt; (isActive ? 'white' : 'inherit')};
  border-bottom: ${({isActive}) =&gt; (isActive ? '1px solid #fff' : 'none')};
  margin-bottom: ${({isActive}) =&gt; (isActive ? '-1px' : '0')};
`

const TabContent = styled.div`
  overflow: auto;
`

const TabView = createComponent(tab, ({}, tab) =&gt; (
  {tab === 'console' &amp;&amp; }
))

const ToolbarView = createComponent(tab, ({}, tab) =&gt; (
  
    
      Console
    
  
))

const SecondanaryTabs = styled.div`
  display: flex;
  flex-direction: column;
  background: #fff;
  border-left: 1px solid #ddd;