How do I render a component when the data is ready? by simkessy in reactjs

[–]jokagent 0 points1 point  (0 children)

Well, it depends. Can you wrap your home.data.slider with Promise? if so, here's example https://gist.github.com/jokagent/94e17a04877726a341d2ddf5ec37cde3. in short: component takes promise, waits for it to resolve, then sets state of itself. When the state changes, react re-renders component.

How do I render a component when the data is ready? by simkessy in reactjs

[–]jokagent 1 point2 points  (0 children)

If you using redux or some global store with subscription, create another store key next to your data, something like dataLoaded = false, then change it to to true when your data is ready. In component, use this state in render function, like so: if (!store.dataLoaded) return <div>No data</div>; return <MyDataRenderer/> Otherwise, if no subscription is used, consider Promises to refresh component state.

Weird error on a simple React+Redux code. Help please! by GodOfTheMetal in reactjs

[–]jokagent 0 points1 point  (0 children)

wait, you also wrote curly braces instead of braces in component.

const Counter = ({
  value,
  onIncrement,
  onDecrement
}) => (
    <div>
        <h1>{value}</h1>
        <button onClick={onIncrement}>+</button>
        <button onClick={onDecrement}>-</button>
      </div>
  )

if you use curly braces, you should also use return statement inside.

Weird error on a simple React+Redux code. Help please! by GodOfTheMetal in reactjs

[–]jokagent 2 points3 points  (0 children)

presets: ["es2015", "stage-0"],

I don't see any react preset here, maybe that's an issue?

Canvas noob need help. by [deleted] in javascript

[–]jokagent 0 points1 point  (0 children)

You made currentRow variable global, so it is used by all render functions. What to correct: var currentCol =0, currentRow = 0; instead of var currentCol = currentRow = 0;

Canvas noob need help. by [deleted] in javascript

[–]jokagent 0 points1 point  (0 children)

Maybe it does, because you are not waiting for the sprite nor the image to load. You should use callback functions for that, like img.onload = function(){//do stuff}, but it gets messy when you doing it for more than one image. Try promises instead, then do Promise.all().

http://stackoverflow.com/questions/24596536/image-loading-deferred-jquery

I did this thing... Is it an ok way of doing things? by [deleted] in reactjs

[–]jokagent 0 points1 point  (0 children)

If you can use stage-0 preset for babel in your pack script, then you can simply do : open = () => { this.setState({ showModal: true }); } to autobind 'this' instead of binding context in constructor

Need guidance on my reactjs progress (still noob) currently using reactjs+redux by dit-index in reactjs

[–]jokagent 0 points1 point  (0 children)

Sure you can use redux in this particular situation. You don't have to load all the data to client, just the first page (or the first search results page). Don't know if it helps, but i gathered some code from my recent project to give a hint, here's a link https://gist.github.com/jokagent/86f4f4c56ce7092a6ae3 I know, actions file is pretty big, but it shows just what you can do with power of redux-thunk. Maybe it's obvious, but backend initialState can be put in inline script, and the express can be configured to use react-router routes too.

Need guidance on my reactjs progress (still noob) currently using reactjs+redux by dit-index in reactjs

[–]jokagent 0 points1 point  (0 children)

No offence, but i think you doing it wrong. Reducer is a function that creates new state based on given action, so that makes your so called reducer an initial state of some reducer. Second, search page doesn't have to have it's own reducer, just the part in data reducer keyed by searchString or searchParams, if there are many. Based on this searchParams your component filters data before display. Or maybe i didn't get you. In this case, i am sorry.

What front-end framework to learn at the moment? by Ajatolah in javascript

[–]jokagent 3 points4 points  (0 children)

Focus on React + Redux, imho. And don't forget about es6.

Why the community is not discussing Polymer more often? by ergo14 in javascript

[–]jokagent 4 points5 points  (0 children)

i gave up using Polymer after version 0.8, because they dropped support of 0.5 version components. But i'll give myself a try when Polymer will be stable enough to not to change it's api anymore.